Submission #787316

# Submission time Handle Problem Language Result Execution time Memory
787316 2023-07-19T05:06:57 Z 박상훈(#10032) 즐거운 사진 수집 (JOI13_collecting) C++17
0 / 100
9 ms 1052 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int cntR[21][1<<21], cntC[21][1<<21], R[21][1<<21], C[21][1<<21];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, q;
	cin >> n >> q;

	ll ans = 1;
	for (int i=1;i<=n;i++){
		cntR[i][0] = 1<<(n-i);
		cntC[i][0] = 1<<(n-i);
	}

	// int sz = 1<<n;

	while(q--){
		int op, x;
		scanf("%d %d", &op, &x);
		--x;

		if (op==0){
			for (int i=1;i<=n;i++){
				int &msk = R[i][x>>i];
				if (msk==0 || msk==((1<<i)-1)) ans += (4LL) * cntC[i][msk];
				// printf("add %lld\n", (1LL<<(i*2)) * cntC[i][msk]);
				cntR[i][msk]--;

				msk ^= 1<<(x&((1<<i)-1));
				if (msk==0 || msk==((1<<i)-1)) ans -= (4LL) * cntC[i][msk];
				cntR[i][msk]++;
			}
		}

		else{
			for (int i=1;i<=n;i++){
				int &msk = C[i][x>>i];
				if (msk==0 || msk==((1<<i)-1)) ans += (4LL) * cntR[i][msk];
				cntC[i][msk]--;

				msk ^= 1<<(x&((1<<i)-1));
				if (msk==0 || msk==((1<<i)-1)) ans -= (4LL) * cntR[i][msk];
				cntC[i][msk]++;
			}
		}

		printf("%lld\n", ans);
	}
}

Compilation message

collecting.cpp: In function 'int main()':
collecting.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d %d", &op, &x);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 1052 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -