#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[1025], col[1025];
ll f(ll d, ll x, ll y) {
if (d == n) return 1;
bool chk = false;
ll a = x * (1 << (n - d)), b = y * (1 << (n - 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 |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5061 ms |
448 KB |
Time limit exceeded |
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 |
- |