# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78785 | ekrem | Topovi (COCI15_topovi) | C++98 | 1940 ms | 46492 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 st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;
typedef long long ll;
typedef pair < int , int > ii;
int n, k, p;
ll ans;
map < int , int > r, c, sr, sc;
map < ii , int > ne;
map < int , int > :: iterator it;
void ekle(int x, int y, int z){
ne[mp(x, y)] = z;
ans -= 1ll * sc[r[x]] * n - 1ll * sc[r[x]] * sr[r[x]];
sr[r[x]]--;
ans += 1ll * sc[r[x]] * n - 1ll * sc[r[x]] * sr[r[x]];
r[x] = r[x]^z;
sr[r[x]]++;
ans -= 1ll * sc[r[x]];
ans -= 1ll * sc[c[y]] * n - 1ll * sc[c[y]] * sr[c[y]];
sc[c[y]]--;
ans += 1ll * sc[c[y]] * n - 1ll * sc[c[y]] * sr[c[y]];
c[y] = c[y]^z;
sc[c[y]]++;
ans += 1ll * n - 1ll * sr[c[y]];
}
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d %d %d",&n ,&k, &p);
sr[0] = n;
sc[0] = n;
for(int i = 1; i <= k; i++){
int x, y, z;
scanf("%d %d %d",&x ,&y ,&z);
ekle(x, y, z);
}
for(int i = 1; i <= p; i++){
int x, y, z, k;
scanf("%d %d %d %d",&x ,&y ,&z ,&k);
int xx = ne[mp(x, y)];
ekle(x, y, xx);
ekle(z, k, xx);
ne[mp(z, k)] = xx;
printf("%lld\n", ans);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |