#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline void fastio() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
}
ll n, q;
bool row[1 << 10 | 1], col[1 << 10 | 1];
ll f(ll d, ll x, ll y) {
if (d == n) return 1;
bool chk = false;
ll a = x * (1 << d), b = y * (1 << d);
for (ll i = a + 1; i - a < 1 << (n - d); i++) {
chk |= row[i - 1] != row[i];
}
for (ll i = b + 1; i - b < 1 << (n - d); i++) {
chk |= col[i - 1] != col[i];
}
if (!chk) {
return 1;
} else {
ll ret = 1;
ret += f(d + 1, x << 1, y << 1);
ret += f(d + 1, x << 1 | 1, y << 1);
ret += f(d + 1, x << 1, y << 1 | 1);
ret += f(d + 1, x << 1 | 1, y << 1 | 1);
return ret;
}
}
int main() {
fastio();
cin >> n >> q;
while (q--) {
ll t, x;
cin >> t >> x;
if (t) {
col[x - 1] ^= 1;
} else {
row[x - 1] ^= 1;
}
cout << f(0, 0, 0) << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |