#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;
sr[r[x]]--;
r[x] = r[x]^z;
sr[r[x]]++;
sc[c[y]]--;
c[y] = c[y]^z;
sc[c[y]]++;
ans = 0;
for(it = sc.begin(); it != sc.end(); it++){
ans += 1ll * it->nd * n;
ans -= 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(it = sc.begin(); it != sc.end(); it++){
ans += 1ll * it->nd * n;
ans -= 1ll * it->nd * sr[it->st];
}
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:36: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:41: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:50: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 |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
612 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
3 ms |
776 KB |
Output is correct |
6 |
Correct |
487 ms |
6460 KB |
Output is correct |
7 |
Correct |
855 ms |
6488 KB |
Output is correct |
8 |
Correct |
455 ms |
6488 KB |
Output is correct |
9 |
Correct |
457 ms |
6884 KB |
Output is correct |
10 |
Correct |
369 ms |
7712 KB |
Output is correct |
11 |
Execution timed out |
2060 ms |
12244 KB |
Time limit exceeded |
12 |
Execution timed out |
2069 ms |
13236 KB |
Time limit exceeded |
13 |
Execution timed out |
2051 ms |
14244 KB |
Time limit exceeded |
14 |
Execution timed out |
2057 ms |
15640 KB |
Time limit exceeded |
15 |
Execution timed out |
2060 ms |
16408 KB |
Time limit exceeded |
16 |
Execution timed out |
2048 ms |
17656 KB |
Time limit exceeded |
17 |
Execution timed out |
2051 ms |
18920 KB |
Time limit exceeded |
18 |
Execution timed out |
2060 ms |
20188 KB |
Time limit exceeded |
19 |
Execution timed out |
2057 ms |
21192 KB |
Time limit exceeded |
20 |
Execution timed out |
2063 ms |
22200 KB |
Time limit exceeded |