Submission #8257

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

int n, k[MAXN][3], a[70000];

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, 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]++;
        if(i%3==0) a[i/3]=i;
    }
    st=0, fn=n/3;
    while(st<=fn)
    {
        mid=(st+fn)/2;
        if(find(a[mid])==false) fn=mid-1;
        else if(find(a[mid])==true) st=mid+1, out=a[mid];
    }
    printf("%d",out);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3704 KB Output isn't correct
2 Halted 0 ms 0 KB -