Submission #1593756
Source Code Expand
#include <bits/stdc++.h> using namespace std; char sd[10010]; int nxt[10010],now[26],st[26]; int main() { scanf("%s",sd+1); for(int i=1;i<=strlen(sd+1);i++) { if(now[sd[i]-'a']==0) st[sd[i]-'a']=i,now[sd[i]-'a']=i; else nxt[now[sd[i]-'a']]=i,now[sd[i]-'a']=i; } // for(int i=1;i<=strlen(sd+1);i++) printf("%d ",nxt[i]); printf("\n"); // for(int i=0;i<26;i++) printf("%d ",st[i]); printf("\n"); int Ans=10000; for(int i=0;i<26;i++) { int ret=st[i]-1,nw=st[i]; if(st[i]==0) continue; while(1) { //cout << nw << endl; if(nxt[nw]==0) { ret=max(ret,(int)strlen(sd+1)-nw); break; } ret=max(ret,nxt[nw]-nw-1); nw=nxt[nw]; } Ans=min(Ans,ret); } cout << Ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Shrinking |
User | wcz111 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 760 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:9:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s",sd+1); ^
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 | 2 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 |