题目:
分析:
表示是来自
X
C
XC
XC的良心送分题
果断暴力不解释
代码:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<ctime>
#include<iomanip>
#include<string>
#include<bitset>
#include<deque>
#include<set>
#define LL long long
#define ch cheap
using namespace std;
inline LL read() {
LL d=0,f=1;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
return d*f;
}
int min(int x,int y) {return x<y?x:y;}
int ans=99999999;
int m,c[150];
int main()
{
int n=read();
string s;
cin>>s;
for(int i=0;i<n;i++)
if(!c[s[i]]) m++,c[s[i]]=1;
for(int i=0;i<n;i++)
{
if(s[i]==s[i+1]) continue;
memset(c,0,sizeof(c));
int j=i,w=0;
while(j<n&&w<m)
{
if(!c[s[j]]) c[s[j]]=1,w++;
j++;
}
if(w<m) break;
ans=min(ans,j-i);
}
cout<<ans;
return 0;
}