This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N=26;
int res=0, n;
int pre[N][N], premin[N][N], last[N][N];
string s;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>s;
for(int i=0; i<N; i++)
for(int j=0; j<N; j++) premin[i][j]=1e9;
for(int i=0; i<n; i++)
{
int a=s[i]-'a';
for(int b=0; b<N; b++)
if(a!=b)
{
pre[a][b]++;
res=max(res, pre[a][b]-premin[a][b]);
premin[b][a]=min(premin[b][a], last[b][a]);
last[b][a]=--pre[b][a];
res=max(res, pre[b][a]-premin[b][a]);
}
}
cout<<res;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |