Submission #1369646
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cstdio> #include <cstring> using namespace std; int main() { char S[101]; if (scanf("%s", S) < 1) return 0; int mincnt = strlen(S); for (char i = 'a'; i <= 'z'; i++) { int cnt = 0; char X[101]; strcpy(X, S); bool flg = true; int len = strlen(X) - 1; for (int k = 0; k < len; k++) { if (X[k] != X[k + 1]) { flg = false; break; } } while (!flg) { for (int j = 0; j < len; j++) { if (X[j] != i && X[j + 1] == i) X[j] = i; else if (X[j] != i && X[j] != X[j + 1]) X[j] = X[j + 1]; } X[len] = '\0'; flg = true; len = strlen(X) - 1; for (int k = 0; k < len; k++) { if (X[k] != X[k + 1]) { flg = false; break; } } cnt++; } mincnt = min(mincnt, cnt); } printf("%d\n", mincnt); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Shrinking |
User | ShinjiSHIBATA |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1257 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 128 KB |
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 | 128 KB |
0_01.txt | AC | 1 ms | 128 KB |
0_02.txt | AC | 1 ms | 128 KB |
0_03.txt | AC | 1 ms | 128 KB |
1_00.txt | AC | 1 ms | 128 KB |
1_01.txt | AC | 1 ms | 128 KB |
1_02.txt | AC | 1 ms | 128 KB |
1_03.txt | AC | 1 ms | 128 KB |
1_04.txt | AC | 1 ms | 128 KB |
1_05.txt | AC | 1 ms | 128 KB |
1_06.txt | AC | 1 ms | 128 KB |
1_07.txt | AC | 1 ms | 128 KB |
1_08.txt | AC | 1 ms | 128 KB |
1_09.txt | AC | 1 ms | 128 KB |