이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
map<int, int> a;
int n;
string s;
int hashed[200005];
int cj, co, ci;
int lel(int x, int y, int z)
{
int ax=min(x, min(y,z));
x-=ax, y-=ax, z-=ax;
return x*200000*200000+y*200000+z;
}
signed main()
{
cin>>n;
cin>>s;
for(int i=0; i<n; i++)
{
if(s[i]=='J')
{
cj++;
}
if(s[i]=='O')
{
co++;
}
if(s[i]=='I')
{
ci++;
}
hashed[i]=lel(ci,co,cj);
a[hashed[i]]=1000000000;
}
for(int i=n-1; i>=0; i--)
{
a[hashed[i]]=min(a[hashed[i]], i);
}
a[0]=-1;
int ans=0;
for(int i=0; i<n; i++)
{
ans=max(ans, i-a[hashed[i]]);
}
cout<<ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |