Submission #1359340
Source Code Expand
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
char in[105];
bool chk[105];
bool tchk[105];
int main() {
scanf("%s", in);
int N = strlen(in), i, j, k, ans = INF;
for (i = 0; i < 26; i++) {
for (j = 0; j < N; j++) chk[j] = (in[j] == 'a' + i);
int c = 0, x = N;
for (c = 0;; c++) {
for (j = 0; j < x; j++) if (!chk[j]) break;
if (j >= x) {
ans = min(ans, c);
break;
}
if (x == 1) break;
for (j = 0; j + 1 < x; j++) tchk[j] = chk[j] | chk[j + 1];
for (j = 0; j + 1 < x; j++) chk[j] = tchk[j];
x--;
}
}
return !printf("%d\n", ans);
}
Submission Info
Submission Time
2017-06-18 21:03:09+0900
Task
A - Shrinking
User
dotorya
Language
C++14 (GCC 5.4.1)
Score
300
Code Size
1782 Byte
Status
AC
Exec Time
1 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:58:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", in);
^
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