# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
991335 | gmroh06 | 즐거운 사진 수집 (JOI13_collecting) | C++14 | 808 ms | 78420 KiB |
이 제출은 이전 버전의 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, MAX;
ll row_tree[1 << 21], col_tree[1 << 21];
ll row[21], col[21];
void update(ll* tree, ll* cnt, ll loc) {
loc |= MAX;
tree[loc] ^= 1;
ll d = n;
while (loc > 1) {
loc >>= 1, d--;
if (tree[loc] % (1LL << n - d) == 0) cnt[d]--;
tree[loc] = tree[loc << 1] + tree[loc << 1 | 1];
if (tree[loc] % (1LL << n - d) == 0) cnt[d]++;
}
}
int main() {
fastio();
cin >> n >> q;
MAX = 1 << n;
for (ll i = 0; i <= 20; i++) {
row[i] = col[i] = 1LL << i;
}
while (q--) {
ll t, x, ans = 1LL << 2 * n;
cin >> t >> x;
t ? update(col_tree, col, x - 1) : update(row_tree, row, x - 1);
for (ll i = 0; i < n; i++) {
ans += 1LL << 2 * i;
ans -= row[i] * col[i] * 4;
}
cout << ans << '\n';
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |