Submission #1589918
Source Code Expand
#include<iostream> #include<algorithm> #include<functional> #include<string> #include<vector> #include<map> #include<set> #include<tuple> #include<stack> #include<queue> #include<deque> #include<sstream> #include<stdio.h> #include<math.h> #include<stdlib.h> #include<bitset> #include<time.h> #include<cstdlib> #include<cassert> #define ll long long #define fi first #define se second using namespace std; string s; bool table[100]; inline bool check(string s,char a){ for(int i=0;i<(int)s.length();i++){ if(s[i]!=a)return 0; } return 1; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<<fixed; #ifdef LOCAL_DEFINE freopen("in", "r", stdin); freopen("out","w",stdout); #endif cin>>s; for(int i=0;i<(int)s.length();i++){ table[s[i]-'a']=1; } string ss; int ans=999999999; for(char now='a';now<='z';now++){ if(!table[now-'a'])continue; ss=s; string t=""; int nowans=0; while(!check(ss,now)){ for(int i=0;i<(int)ss.length()-1;i++){ if(ss[i]==(char)now || ss[i+1]==(char)now){ t+=now; }else{ t+=ss[i]; } } ss=t; t=""; nowans++; } ans=min(ans,nowans); } cout<<ans<<"\n"; #ifdef LOCAL_DEFINE cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Shrinking |
User | aim_cpo |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1461 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 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 | 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 | 2 ms | 256 KB |
1_09.txt | AC | 2 ms | 256 KB |