Educational Codeforces Round 32
#include<bits/stdc++.h>
using namespace std;
#define maxn 100000+10
char a[maxn];
int len;
int check(int x){
int c[26+10];
memset(c,0,sizeof(c));
for(int j=0;j<x;j++){
c[a[j]-'a']++;
}
int sum=0;
for(int j=0;j<26;j++){
if(c[j]) sum++;
else c[j]=-1;
}
for(int j=x;j<len;j++){
if(c[a[j]-'a']>0){
c[a[j]-'a']++;
}
c[a[j-x]-'a']--;
if(c[a[j-x]-'a']==0){
sum--;
}
if(sum==0) return 0;
}
return 1;
}
int main(){
cin>>a;
len=strlen(a);
int l=0,r=len;
while(l<r){
int mid=(l+r)/2;
if(check(mid)){
r=mid;
}
else {
l=mid+1;
}
}
cout<<l<<endl;
return 0;
}
相關文章
- Codeforces Educational Round#98 A
- Educational Codeforces Round 1 Tutorial
- Educational Codeforces Round 163
- 【題解】Educational Codeforces Round 82
- Educational Codeforces Round 171 (Div. 2)
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)
- Codeforces Beta Round #32
- Educational Codeforces Round 37 (Rated for Div. 2)
- Educational Codeforces Round 93 (Rated for Div. 2)
- Educational Codeforces Round 96 A-E 題解
- Educational Codeforces Round 170 (Rated for Div. 2)
- Educational Codeforces Round 171 div2(A~E)
- Educational Codeforces Round 19 E. Array Queries
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)B
- Educational Codeforces Round 100-C. Busy Robot
- Educational Codeforces Round 100 (Rated for Div. 2)
- Educational Codeforces Round 33 (Rated for Div. 2) C
- Educational Codeforces Round 34 (Rated for Div. 2) D
- Educational Codeforces Round 163 (Rated for Div. 2)
- Educational Codeforces Round 154 (Rated for Div. 2)
- Educational Codeforces Round 168 (Rated for Div. 2)
- Educational Codeforces Round 166 個人題解(A~D)
- Educational Codeforces Round 166(A-D題解)
- Educational Codeforces Round 93 (Rated for Div. 2)題解
- Educational Codeforces Round 170 (Rated for Div. 2) A-D
- Educational Codeforces Round 170 (Rated for Div. 2) ABCD
- Educational Codeforces Round 171 (Rated for Div. 2) 題解
- Educational Codeforces Round 168 (Rated for Div. 2) A - E
- 【CodeForces訓練記錄】Educational Codeforces Round 171 (Rated for Div. 2)
- Educational Codeforces Round 143 (Rated for Div. 2) A-E
- Educational Codeforces Round 142 (Rated for Div. 2) A-D
- vp Educational Codeforces Round 168 (Rated for Div. 2) A - E
- Educational Codeforces Round 168 (Rated for Div. 2) 題解
- Educational Codeforces Round 4 D The Union of k-Segments (掃描線)
- Educational Codeforces Round 95 (Rated for Div. 2) G. Three Occurrences
- Educational Codeforces Round 163 (Rated for Div. 2) - VP記錄
- Educational Codeforces Round 166 (Rated for Div. 2) - VP記錄
- Educational Codeforces Round 162 (Rated for Div. 2) - VP記錄