#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) x.begin(),x.end()
#define LINE 0
#define COLOUMN 1
using i64=long long;
map<int,int>value[2],cnt[2];
map<pair<int,int>,int>mpp;
int n;
i64 cost;
void add(int poz,int val,bool tip)
{
cost-=(n-cnt[tip^1][value[tip][poz]]);
cnt[tip][value[tip][poz]]--;
value[tip][poz]^=val;
cnt[tip][value[tip][poz]]++;
cost+=(n-cnt[tip^1][value[tip][poz]]);
}
void change(int l1,int r1,int l2,int r2)
{
int vall=mpp[make_pair(l1,r1)];
add(l1,vall,LINE);
add(r1,vall,COLOUMN);
add(l2,vall,LINE);
add(r2,vall,COLOUMN);
mpp[make_pair(l2,r2)]=vall;
}
int main()
{
int k,q;
cin>>n>>k>>q;
cnt[LINE][0]=n;
cnt[COLOUMN][0]=n;
for(int i=0;i<k;i++)
{
int x,y,k;
cin>>x>>y>>k;
add(x,k,LINE);
add(y,k,COLOUMN);
mpp[make_pair(x,y)]=k;
}
while(q--)
{
int l1,r1,l2,r2;
cin>>l1>>r1>>l2>>r2;
change(l1,r1,l2,r2);
cout<<cost<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
119 ms |
5200 KB |
Output is correct |
7 |
Correct |
93 ms |
4688 KB |
Output is correct |
8 |
Correct |
91 ms |
3924 KB |
Output is correct |
9 |
Correct |
88 ms |
4080 KB |
Output is correct |
10 |
Correct |
84 ms |
4060 KB |
Output is correct |
11 |
Correct |
1014 ms |
33412 KB |
Output is correct |
12 |
Correct |
1037 ms |
33448 KB |
Output is correct |
13 |
Correct |
1052 ms |
33368 KB |
Output is correct |
14 |
Correct |
1022 ms |
33460 KB |
Output is correct |
15 |
Correct |
1002 ms |
33484 KB |
Output is correct |
16 |
Correct |
1004 ms |
33880 KB |
Output is correct |
17 |
Correct |
1036 ms |
33432 KB |
Output is correct |
18 |
Correct |
1076 ms |
33560 KB |
Output is correct |
19 |
Correct |
998 ms |
33616 KB |
Output is correct |
20 |
Correct |
1016 ms |
33404 KB |
Output is correct |