题解:用两个指针移动判断右指针移动到r位置,l位置最小能在哪里然后就是r-l+1,取其中最大值即可
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<cstdlib>
#include<ctime>
#include<stack>
using namespace std;
#define mes(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(i = a; i <= b; i++)
#define dec(i,a,b) for(i = b; i >= a; i--)
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define mid (L+R)/2
#define lson ls,L,mid
#define rson rs,mid+1,R
typedef double db;
typedef long long int ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int mx = 1e7+5;
const int x_move[] = {1,-1,0,0,1,1,-1,-1};
const int y_move[] = {0,0,1,-1,1,-1,1,-1};
int n,m;
char s[mx];
bool mark[256];
int main(){
int t,q,ca = 1;
while(scanf("%d",&n)!=EOF){
scanf("%s",s);
mes(mark,0);
int L = 0,R = 0;
int l = 0;
mark[s[0]] = 1;
for(int r = 1; s[r]; r++){
while(mark[s[r]]){
mark[s[l]] = 0;
l++;
}
mark[s[r]] = 1;
if(r-l+1>R-L+1)
R = r,L = l;
}
printf("%d %d %d\n",R-L+1,L,R);
}
return 0;
}