Submission #12960

# Submission time Handle Problem Language Result Execution time Memory
12960 2015-01-21T14:19:51 Z gs13068 즐거운 사진 수집 (JOI13_collecting) C++
100 / 100
1548 ms 17472 KB
#include<cstdio>

int T[2][2097152];
long long d[2][20];

int main()
{
	long long r=0;
    int i,j,k,n,m;
    scanf("%d%d",&n,&m);
    for(i=0;i<2;i++)for(j=1;j<(2<<n);j++)T[i][j]=1;
    for(i=0;i<2;i++)for(j=0;j<n;j++)d[i][j]=1<<j;
    while(m--)
	{
		scanf("%d%d",&i,&j);
		j+=(1<<n)-1;
		T[i][j]=-T[i][j];
		for(k=n-1;j>>=1;k--)
		{
			r+=d[0][k]*d[1][k];
			d[i][k]-=!!T[i][j];
			T[i][j]=0;
			if(T[i][j<<1]==T[i][(j<<1)+1])T[i][j]=T[i][j<<1];
			d[i][k]+=!!T[i][j];
			r-=d[0][k]*d[1][k];
		}
        printf("%lld\n",(r<<2)+1);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17472 KB Output is correct
2 Correct 0 ms 17472 KB Output is correct
3 Correct 0 ms 17472 KB Output is correct
4 Correct 0 ms 17472 KB Output is correct
5 Correct 0 ms 17472 KB Output is correct
6 Correct 0 ms 17472 KB Output is correct
7 Correct 0 ms 17472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17472 KB Output is correct
2 Correct 0 ms 17472 KB Output is correct
3 Correct 0 ms 17472 KB Output is correct
4 Correct 0 ms 17472 KB Output is correct
5 Correct 0 ms 17472 KB Output is correct
6 Correct 0 ms 17472 KB Output is correct
7 Correct 0 ms 17472 KB Output is correct
8 Correct 0 ms 17472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1540 ms 17472 KB Output is correct
2 Correct 1468 ms 17472 KB Output is correct
3 Correct 1332 ms 17472 KB Output is correct
4 Correct 1508 ms 17472 KB Output is correct
5 Correct 1432 ms 17472 KB Output is correct
6 Correct 1524 ms 17472 KB Output is correct
7 Correct 1548 ms 17472 KB Output is correct
8 Correct 1464 ms 17472 KB Output is correct
9 Correct 1344 ms 17472 KB Output is correct
10 Correct 1368 ms 17472 KB Output is correct
11 Correct 1428 ms 17472 KB Output is correct
12 Correct 1464 ms 17472 KB Output is correct
13 Correct 1344 ms 17472 KB Output is correct