#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef __int64 LL; const int maxn = 1e6+10; char str[maxn]; pair p[maxn]; LL sign[3000]; LL solve(LL k) { LL u=0; memset(sign,0,sizeof(sign)); LL len; len=strlen(str); LL l,r; l=0; r=-1; LL now=0; LL ans=0; while(now=len) break; if(!sign[str[r]]) now++; sign[str[r]]++; } while(1) { if(sign[str[l]]>1) l++,sign[str[l-1]]--; else break; } if(now==k) p[u].first=l,p[u++].second=r; else return 0; while(r=k) { sign[str[l]]--; if(!sign[str[l]]) now--; l++; if(l>=len) break; } else { r++; if(r>=len) break; if(!sign[str[r]]) now++; sign[str[r]]++; if(now==k) { while(1) { if(sign[str[l]]>1) l++,sign[str[l-1]]--; else break; } p[u].first=l,p[u++].second=r; } } } //for(int i=0; i