Submission #8256

# Submission time Handle Problem Language Result Execution time Memory
8256 2014-09-08T15:04:24 Z ansol4328 JOIOJI (JOI14_joioji) C++
0 / 100
0 ms 3432 KB
#include<stdio.h>
#define MAXN 200005

int n, k[MAXN][3];

bool find(int x)
{
    int i, c1, c2, c3;
    for(i=0 ; i<=n-x ; i++)
    {
        c1=k[i+x][0]-k[i][0];
        c2=k[i+x][1]-k[i][1];
        c3=k[i+x][2]-k[i][2];
        if(c1==c2 && c2==c3 && c3==c1) break;
    }
    if(i<=n-x) return true;
    else return false;
}

int main()
{
    int i, out=0, st, fn, mid;
    char m;
    scanf("%d ",&n);
    for(i=1 ; i<=n ; i++)
    {
        scanf("%c",&m);
        k[i][0]=k[i-1][0];
        k[i][1]=k[i-1][1];
        k[i][2]=k[i-1][2];
        if(m=='J') k[i][0]++;
        if(m=='O') k[i][1]++;
        if(m=='I') k[i][2]++;
    }
    st=1, fn=n;
    while(st<=fn)
    {
        mid=(st+fn)/2;
        while(mid%3!=0) mid++;
        if(mid>fn) break;
        if(find(mid)==false) fn=mid-1;
        else if(find(mid)==true) st=mid+1, out=mid;
    }
    printf("%d",out);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3432 KB Output is correct
2 Incorrect 0 ms 3432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3432 KB Output isn't correct
2 Halted 0 ms 0 KB -