# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
489751 |
2021-11-24T08:14:36 Z |
cpp219 |
Topovi (COCI15_topovi) |
C++14 |
|
627 ms |
32792 KB |
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define debug(y) cout<<y,exit(0)
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e6 + 9;
const ll inf = 1e9 + 7;
map<LL,ll> power;
unordered_map<ll,ll> cntA,cntB,r,c;
ll n,k,Q,ans;
void update(ll x,ll y,ll val){
ll nwB = r[x] ^ val,nwA = c[y] ^ val;
ans += cntA[r[x]] - cntA[nwB];
cntB[r[x]]--; cntB[nwB]++; r[x] = nwB;
ans += cntB[c[y]] - cntB[nwA];
cntA[c[y]]--; cntA[nwA]++; c[y] = nwA;
}
ll x,y,w;
int main(){
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define task "tst"
if (fopen(task".inp","r")){
freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
}
cin>>n>>k>>Q; cntA[0] = cntB[0] = n;
while(k--){
cin>>x>>y>>w; update(x,y,w);
power[{x,y}] = w;
}
//debug(ans);
while(Q--){
ll x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
update(x1,y1,power[{x1,y1}]); update(x2,y2,power[{x1,y1}]);
swap(power[{x2,y2}],power[{x1,y1}]);
cout<<ans<<"\n";
}
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/
Compilation message
topovi.cpp: In function 'int main()':
topovi.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
30 | freopen(task".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
45 ms |
4908 KB |
Output is correct |
7 |
Correct |
41 ms |
4560 KB |
Output is correct |
8 |
Correct |
34 ms |
3912 KB |
Output is correct |
9 |
Correct |
28 ms |
3996 KB |
Output is correct |
10 |
Correct |
41 ms |
4092 KB |
Output is correct |
11 |
Correct |
603 ms |
32628 KB |
Output is correct |
12 |
Correct |
575 ms |
32596 KB |
Output is correct |
13 |
Correct |
542 ms |
32704 KB |
Output is correct |
14 |
Correct |
592 ms |
32584 KB |
Output is correct |
15 |
Correct |
576 ms |
32792 KB |
Output is correct |
16 |
Correct |
577 ms |
32656 KB |
Output is correct |
17 |
Correct |
557 ms |
32632 KB |
Output is correct |
18 |
Correct |
627 ms |
32724 KB |
Output is correct |
19 |
Correct |
594 ms |
32704 KB |
Output is correct |
20 |
Correct |
552 ms |
32680 KB |
Output is correct |