Submission #10956

# Submission time Handle Problem Language Result Execution time Memory
10956 2014-11-13T06:06:21 Z dohyun0324 JOIOJI (JOI14_joioji) C++
100 / 100
48 ms 14764 KB
#include<stdio.h>
#include<map>
using namespace std;
map<long long,long long>m;
char s[200010];
long long int p,len,dap,a[200010],b[200010],c[200010];
long long int arr1[200010],arr2[200010];
int main()
{
    int i;
    scanf("%lld",&len);
    scanf("%s",s);
    for(i=0;i<len;i++)
    {
        a[i]=a[i-1]; b[i]=b[i-1]; c[i]=c[i-1];
        if(s[i]=='J') a[i]=a[i-1]+1;
        if(s[i]=='O') b[i]=b[i-1]+1;
        if(s[i]=='I') c[i]=c[i-1]+1;
    }
    for(i=0;i<len;i++) arr1[i]=a[i]-b[i]+100000, arr2[i]=b[i]-c[i]+100000;
    for(i=0;i<len;i++)
    {
        if(arr1[i]==100000 && arr2[i]==100000 && dap<i+1) dap=i+1;
    }
    for(i=0;i<len;i++)
    {
        if(m[arr1[i]*1000000+arr2[i]])
        {
            p=m[arr1[i]*1000000+arr2[i]]-1;
            if(dap<i-p) dap=i-p;
        }
        else m[arr1[i]*1000000+arr2[i]]=i+1;
    }
    printf("%lld",dap);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9220 KB Output is correct
2 Correct 0 ms 9220 KB Output is correct
3 Correct 0 ms 9220 KB Output is correct
4 Correct 0 ms 9220 KB Output is correct
5 Correct 0 ms 9220 KB Output is correct
6 Correct 0 ms 9220 KB Output is correct
7 Correct 0 ms 9220 KB Output is correct
8 Correct 0 ms 9220 KB Output is correct
9 Correct 0 ms 9220 KB Output is correct
10 Correct 0 ms 9220 KB Output is correct
11 Correct 0 ms 9220 KB Output is correct
12 Correct 0 ms 9220 KB Output is correct
13 Correct 0 ms 9220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9220 KB Output is correct
2 Correct 0 ms 9220 KB Output is correct
3 Correct 0 ms 9220 KB Output is correct
4 Correct 0 ms 9220 KB Output is correct
5 Correct 0 ms 9220 KB Output is correct
6 Correct 0 ms 9220 KB Output is correct
7 Correct 0 ms 9220 KB Output is correct
8 Correct 0 ms 9220 KB Output is correct
9 Correct 0 ms 9220 KB Output is correct
10 Correct 0 ms 9352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9352 KB Output is correct
2 Correct 8 ms 9748 KB Output is correct
3 Correct 4 ms 10144 KB Output is correct
4 Correct 12 ms 10936 KB Output is correct
5 Correct 28 ms 11992 KB Output is correct
6 Correct 44 ms 12124 KB Output is correct
7 Correct 44 ms 12520 KB Output is correct
8 Correct 40 ms 11992 KB Output is correct
9 Correct 44 ms 12256 KB Output is correct
10 Correct 48 ms 11992 KB Output is correct
11 Correct 40 ms 13708 KB Output is correct
12 Correct 20 ms 10804 KB Output is correct
13 Correct 24 ms 10144 KB Output is correct
14 Correct 24 ms 14764 KB Output is correct
15 Correct 12 ms 9748 KB Output is correct