Submission #12959

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

int T[2][2097152];
int 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);
		for(j+=(1<<n)-1,k=n-1;j;j>>=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=0;
        for(i=0;i<n;i++)r+=((1LL<<i)<<i)-1LL*d[0][i]*d[1][i];
        printf("%lld\n",(r<<2)+1);
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 17472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -