# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98623 | minhtung0404 | Topovi (COCI15_topovi) | C++17 | 3 ms | 384 KiB |
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>
const int N = 1e5 + 5;
using namespace std;
typedef pair <int, int> ii;
map <int, int> mp[2], val[2];
map <ii, int> ro;
int n, k, p;
long long ans;
void add(int i, int num, int x, int v){
ans += 1LL * mp[0][val[i][num]] * mp[1][val[i][num]];
mp[i][val[i][num]]--;
val[i][num] ^= x;
mp[i][val[i][num]]++;
ans -= 1LL * mp[0][val[i][num]] * mp[1][val[i][num]];
}
int main(){
freopen("TOPOVI.inp", "r", stdin);
freopen("TOPOVI.out", "w", stdout);
cin >> n >> k >> p;
ans = k * k;
while (k--){
int r, c, x;
cin >> r >> c >> x;
add(0, r, x, 1); add(1, c, x, 1);
ro[ii(r,c)] = 1;
}
while (p--){
int r1, c1, r2, c2;
cin >> r1 >> c1 >> r2 >> c2;
int x = ro[ii(r1,c1)];
ro[ii(r1,c1)] = 0; ro[ii(r2,c2)] = x;
add(0, r1, x, -1); add(1, c1, x, -1);
add(0, r2, x, +1); add(1, c2, x, +1);
cout << ans << "\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |