이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |