#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;
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]];
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;
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]];
// for(it = sc.begin(); it != sc.end(); it++)
// ans += 1ll * it->nd * n - 1ll * it->nd * sr[it->st];
}
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);
printf("%lld\n", ans);
}
return 0;
}
Compilation message
topovi.cpp: In function 'int main()':
topovi.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d",&n ,&k, &p);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d",&x ,&y ,&z);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d %d",&x ,&y ,&z ,&k);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
380 KB |
Output is correct |
3 |
Correct |
3 ms |
440 KB |
Output is correct |
4 |
Correct |
3 ms |
612 KB |
Output is correct |
5 |
Correct |
3 ms |
612 KB |
Output is correct |
6 |
Correct |
317 ms |
5496 KB |
Output is correct |
7 |
Correct |
246 ms |
5496 KB |
Output is correct |
8 |
Correct |
196 ms |
5496 KB |
Output is correct |
9 |
Correct |
198 ms |
5496 KB |
Output is correct |
10 |
Correct |
231 ms |
5496 KB |
Output is correct |
11 |
Execution timed out |
2070 ms |
34496 KB |
Time limit exceeded |
12 |
Execution timed out |
2075 ms |
39436 KB |
Time limit exceeded |
13 |
Execution timed out |
2059 ms |
43928 KB |
Time limit exceeded |
14 |
Execution timed out |
2069 ms |
47976 KB |
Time limit exceeded |
15 |
Execution timed out |
2065 ms |
52668 KB |
Time limit exceeded |
16 |
Execution timed out |
2056 ms |
56808 KB |
Time limit exceeded |
17 |
Execution timed out |
2064 ms |
61812 KB |
Time limit exceeded |
18 |
Execution timed out |
2072 ms |
65620 KB |
Time limit exceeded |
19 |
Execution timed out |
2071 ms |
66560 KB |
Time limit exceeded |
20 |
Execution timed out |
2067 ms |
66560 KB |
Time limit exceeded |