# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
210064 | ZwariowanyMarcin | Topovi (COCI15_topovi) | C++14 | 1151 ms | 39544 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>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep2(i, j, n) for (LL i = j; i <= n; ++i)
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define boost cin.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(), x.end()
using namespace std;
const int N = 1e5 + 10101;
map <pair<int, int>, int> mapa;
map <int, int> row, col;
map <int, int> cnt1, cnt2;
int n, k, p, a, b, c, d;
LL ans;
void upd1(int r, int x) {
ans -= cnt2[row[r]];
cnt1[row[r]]--;
row[r] ^= x;
ans += cnt2[row[r]];
cnt1[row[r]]++;
}
void upd2(int c, int x) {
ans -= cnt1[col[c]];
cnt2[col[c]]--;
col[c] ^= x;
ans += cnt1[col[c]];
cnt2[col[c]]++;
}
int main() {
scanf ("%d%d%d", &n, &k, &p);
ans = (LL) n * n;
cnt1[0] = n;
cnt2[0] = n;
rep(i, 1, k) {
scanf ("%d%d%d", &a, &b, &c);
mapa[{a, b}] = c;
upd1(a, c);
upd2(b, c);
}
while (p--) {
scanf ("%d%d%d%d", &a, &b, &c, &d);
int e = mapa[{a, b}];
mapa[{c, d}] = e;
upd1(a, e);
upd2(b, e);
upd1(c, e);
upd2(d, e);
printf ("%lld\n", (LL) n * n - ans);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |