This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |