#include <map>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int ,int > pii;
#define endl '\n'
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
map < int , int > cntstr , cntstn;
map < pii , int > rook;
map < int , int > str , stn;
ll ans = 0;
int n , k , p;
void add(int x ,int y , int w){
rook[{x , y}]^=w;
ans+=(cntstn[str[x]] + cntstr[stn[y]]);
ans+=ll(str[x]!=stn[y]);
cntstr[str[x]]--;
cntstn[stn[y]]--;
str[x]^=w;
stn[y]^=w;
cntstr[str[x]]++;
cntstn[stn[y]]++;
ans-=ll(str[x]!=stn[y]);
ans-=(cntstn[str[x]] + cntstr[stn[y]]);
}
int main(){
migmig
cin >> n >> k >> p;
cntstr[0] = cntstn[0] = n;
for(int i = 0 ; i < n; i ++){
int x , y;
cin >> x >> y;
int w;
cin >> w;
add(x , y , w);
}
while(p--){
int x1 , y1 , x2 , y3;
cin >> x1 >> y1 >> x2 >> y3;
int val = rook[{x1 , y1}];
add(x1 , y1 , val);
add(x2 , y3 , val);
cout << ans << endl;
}
return(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
1164 ms |
8184 KB |
Output isn't correct |
7 |
Incorrect |
611 ms |
6520 KB |
Output isn't correct |
8 |
Incorrect |
861 ms |
5496 KB |
Output isn't correct |
9 |
Incorrect |
894 ms |
5516 KB |
Output isn't correct |
10 |
Incorrect |
946 ms |
6136 KB |
Output isn't correct |
11 |
Execution timed out |
2093 ms |
45572 KB |
Time limit exceeded |
12 |
Execution timed out |
2075 ms |
45688 KB |
Time limit exceeded |
13 |
Execution timed out |
2081 ms |
45608 KB |
Time limit exceeded |
14 |
Execution timed out |
2084 ms |
45688 KB |
Time limit exceeded |
15 |
Execution timed out |
2093 ms |
45432 KB |
Time limit exceeded |
16 |
Execution timed out |
2075 ms |
45624 KB |
Time limit exceeded |
17 |
Execution timed out |
2096 ms |
45432 KB |
Time limit exceeded |
18 |
Execution timed out |
2082 ms |
45520 KB |
Time limit exceeded |
19 |
Execution timed out |
2085 ms |
45560 KB |
Time limit exceeded |
20 |
Execution timed out |
2089 ms |
45432 KB |
Time limit exceeded |