Submission #1774747


Source Code Expand

#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	bool flag = false;
	int check = 0;
	int count = 0;
	int total = INF;
	string s;
	string p;
	string t;

	cin >> s;
	p = s;
	t = s;

	FOR(i, 0, 25) {
		count = 0;
		check = 0;
		flag = false;
		s = p;
		t = s;
		FOR(u, 0, s.size() - 2) {
			if (t[u] != 'a' + i) {
				break;
			}
			if (u == s.size() - 2) {
				total = 0;
				break;
			}
		}
		while (1) {
			FOR(u, 0, s.size() - 2) {
				if (s[u] == 'a' + i || s[u + 1] == 'a' + i) {
					check++;
					t[u] = 'a' + i;
				}

			}
			count++;
			if (check == 0) {
				break;
			}
			t.pop_back();
			FOR(u, 0, s.size() - 2) {
				if (t[u] != 'a' + i) {
					break;
				}
				if (u == s.size() - 2) {
					flag = true;
				}
			}
			s = t;

			if (flag == true) {
				if (count < total) {
					total = count;
				}
				break;
				s = p;
				t = s;
			}
		}

	}
	cout << total << endl;
	return 0;
}

Submission Info

Submission Time
Task A - Shrinking
User yukiteru
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1321 Byte
Status RE
Exec Time 96 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 4
AC × 13
RE × 1
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 RE 96 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 2 ms 256 KB