# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
98695 | Dat160601 | Topovi (COCI15_topovi) | C++17 | 1397 ms | 33600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
long long n, ans;
int k, p, r, c, x;
map <int, int> cnt[2], val[2];
map < pair <int, int>, int > a;
void update(int tp, int pos, int v){
int cur = val[tp][pos];
ans += 1LL * cnt[0][cur] * cnt[1][cur];
cnt[tp][cur]--;
ans -= 1LL * cnt[0][cur] * cnt[1][cur];
cur ^= v;
val[tp][pos] = cur;
ans += 1LL * cnt[0][cur] * cnt[1][cur];
cnt[tp][cur]++;
ans -= 1LL * cnt[0][cur] * cnt[1][cur];
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> k >> p;
cnt[0][0] = cnt[1][0] = n;
while(k --){
cin >> r >> c >> x;
a[mp(r, c)] = x;
update(0, r, x), update(1, c, x);
}
while(p --){
int ar, ac;
cin >> r >> c >> ar >> ac;
x = a[mp(r, c)];
a[mp(r, c)] = 0, a[mp(ar, ac)] = x;
update(0, r, x), update(1, c, x);
update(0, ar, x), update(1, ac, x);
cout << ans << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |