# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
78785 |
2018-10-08T18:10:57 Z |
ekrem |
Topovi (COCI15_topovi) |
C++ |
|
1940 ms |
46492 KB |
#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
topovi.cpp: In function 'int main()':
topovi.cpp:37: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:42: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:47: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);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
380 KB |
Output is correct |
3 |
Correct |
3 ms |
496 KB |
Output is correct |
4 |
Correct |
2 ms |
540 KB |
Output is correct |
5 |
Correct |
3 ms |
544 KB |
Output is correct |
6 |
Correct |
233 ms |
5484 KB |
Output is correct |
7 |
Correct |
173 ms |
5484 KB |
Output is correct |
8 |
Correct |
144 ms |
5484 KB |
Output is correct |
9 |
Correct |
149 ms |
5484 KB |
Output is correct |
10 |
Correct |
158 ms |
5484 KB |
Output is correct |
11 |
Correct |
1851 ms |
38780 KB |
Output is correct |
12 |
Correct |
1851 ms |
42604 KB |
Output is correct |
13 |
Correct |
1840 ms |
43020 KB |
Output is correct |
14 |
Correct |
1839 ms |
43524 KB |
Output is correct |
15 |
Correct |
1883 ms |
44132 KB |
Output is correct |
16 |
Correct |
1940 ms |
44616 KB |
Output is correct |
17 |
Correct |
1867 ms |
44840 KB |
Output is correct |
18 |
Correct |
1875 ms |
45324 KB |
Output is correct |
19 |
Correct |
1844 ms |
45952 KB |
Output is correct |
20 |
Correct |
1913 ms |
46492 KB |
Output is correct |