Submission #2779

# Submission time Handle Problem Language Result Execution time Memory
2779 2013-07-31T09:55:09 Z kk1401 속이기 (GA5_fake) C++
10 / 100
812 ms 44056 KB
#include<stdio.h>

int n,d[1000001],cnt[1000001],ans,chk[1000001];

struct data
{
    int x,y;
}; data dy[2][1000001],cost[2][1000001];

void input()
{
    int i;
    scanf("%d",&n);
    for(i=1; i<=n; i++) scanf("%d",&d[i]);
}

int maxval(int a,int b)
{
    return a>b?a:b;
}

void process()
{
    int i,j,in;
    dy[1][++cnt[1]].x=cost[1][1].x=d[1];
    dy[1][cnt[1]].y=-1; cost[1][1].y=0;
    
    for(i=2; i<=n; i++){
        for(j=1; j<=cnt[i-1]; j++){
            //x에 넣는경우
            in = i%2;
            if(chk[dy[1-in][j].x^d[i]] != i){
                dy[in][++cnt[i]].x = dy[1-in][j].x^d[i];
                dy[in][cnt[i]].y = dy[1-in][j].y;
                cost[in][cnt[i]].y = cost[1-in][j].y;
                cost[in][cnt[i]].x = cost[1-in][j].x + d[i];
                chk[dy[1-in][j].x^d[i]]=i;
            }
            if(chk[dy[1-in][j].x] != i){
                //y에 넣는경우
                if(dy[1-in][j].y==-1) dy[in][++cnt[i]].y = d[i];
                else dy[in][++cnt[i]].y = dy[1-in][j].y^d[i];
                dy[in][cnt[i]].x = dy[1-in][j].x;
                cost[in][cnt[i]].y = cost[1-in][j].y + d[i];
                cost[in][cnt[i]].x = cost[1-in][j].x;
                chk[dy[1-in][j].x] = i;
            }
        }
    }
    for(i=1; i<=cnt[n]; i++) if(dy[n%2][i].x==dy[n%2][i].y) ans=maxval(ans,maxval(cost[n%2][i].x,cost[n%2][i].y));
}

void output()
{
    printf("%d\n",ans);
}
int main()
{
    input();
    process();
    output();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 44056 KB Output is correct
2 Correct 0 ms 44056 KB Output is correct
3 Correct 0 ms 44056 KB Output is correct
4 Correct 0 ms 44056 KB Output is correct
5 Correct 0 ms 44056 KB Output is correct
6 Correct 0 ms 44056 KB Output is correct
7 Correct 0 ms 44056 KB Output is correct
8 Correct 0 ms 44056 KB Output is correct
9 Correct 0 ms 44056 KB Output is correct
10 Correct 0 ms 44056 KB Output is correct
11 Correct 0 ms 44056 KB Output is correct
12 Correct 0 ms 44056 KB Output is correct
13 Correct 0 ms 44056 KB Output is correct
14 Correct 0 ms 44056 KB Output is correct
15 Correct 0 ms 44056 KB Output is correct
16 Correct 0 ms 44056 KB Output is correct
17 Correct 0 ms 44056 KB Output is correct
18 Correct 0 ms 44056 KB Output is correct
19 Correct 0 ms 44056 KB Output is correct
20 Correct 0 ms 44056 KB Output is correct
21 Correct 0 ms 44056 KB Output is correct
22 Correct 0 ms 44056 KB Output is correct
23 Correct 0 ms 44056 KB Output is correct
24 Correct 0 ms 44056 KB Output is correct
25 Correct 0 ms 44056 KB Output is correct
26 Correct 0 ms 44056 KB Output is correct
27 Correct 0 ms 44056 KB Output is correct
28 Correct 0 ms 44056 KB Output is correct
29 Correct 0 ms 44056 KB Output is correct
30 Correct 0 ms 44056 KB Output is correct
31 Correct 0 ms 44056 KB Output is correct
32 Correct 0 ms 44056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 44056 KB Output is correct
2 Correct 0 ms 44056 KB Output is correct
3 Incorrect 4 ms 44056 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 44056 KB Output is correct
2 Incorrect 8 ms 44056 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 812 ms 44052 KB Program hung waiting for input
2 Halted 0 ms 0 KB -