Submission #1359347
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
typedef long long LL;
const int oo = 0x3f3f3f3f;
const int maxn = 110;
int n;
char s[maxn + 5];
int a[maxn + 5];
int main()
{
#ifdef matthew99
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
scanf("%s", s);
n = strlen(s);
REP(i, 0, n) a[i] = s[i] - 'a';
int ans = n;
REP(i, 0, 26)
{
int lst = n;
int tmp = 0;
for (int j = n - 1; j >= 0; --j)
{
if (a[j] == i) lst = j;
chkmax(tmp, lst - j);
}
chkmin(ans, tmp);
}
printf("%d\n", ans);
return 0;
}
Submission Info
Submission Time
2017-06-18 21:03:31+0900
Task
A - Shrinking
User
matthew99
Language
C++14 (GCC 5.4.1)
Score
300
Code Size
1056 Byte
Status
AC
Exec Time
1 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:33:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", s);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
300 / 300
Status
Set Name
Test Cases
Sample
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt
Case Name
Status
Exec Time
Memory
0_00.txt
AC
1 ms
256 KB
0_01.txt
AC
1 ms
256 KB
0_02.txt
AC
1 ms
256 KB
0_03.txt
AC
1 ms
256 KB
1_00.txt
AC
1 ms
256 KB
1_01.txt
AC
1 ms
256 KB
1_02.txt
AC
1 ms
256 KB
1_03.txt
AC
1 ms
256 KB
1_04.txt
AC
1 ms
256 KB
1_05.txt
AC
1 ms
256 KB
1_06.txt
AC
1 ms
256 KB
1_07.txt
AC
1 ms
256 KB
1_08.txt
AC
1 ms
256 KB
1_09.txt
AC
1 ms
256 KB