#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n, k, p;
unordered_map<int, int> col, row, kc, kr;
map<pii, int> mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
#ifdef Local
freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
#endif
cin>>n>>k>>p;
kc[0] = kr[0] = n;
for(int i = 0; i < k; i++){
int x, y, pow;
cin>>x>>y>>pow;
mp[{x, y}] = pow;
kc[col[y]]--;
kr[row[x]]--;
col[y] = (col[y] ^ pow);
row[x] = (row[x] ^ pow);
kc[col[y]]++;
kr[row[x]]++;
}
ll ans = 1LL * n * n;
for(auto u: kc){
ans -= 1LL * u.ss * kr[u.ff];
}
for(int i = 0; i < p; i++){
int x1, y1, x2, y2;
cin>>x1>>y1>>x2>>y2;
auto u = mp.find({x1, y1});
int pwer = (*u).ss;
mp.erase(u);
mp[{x2, y2}] = pwer;
int degR = row[x1], degC = col[y1];
ans += kc[degR];
kr[degR]--;
ans += kr[degC];
kc[degC]--;
row[x1] ^= pwer;
col[y1] ^= pwer;
ans -= kr[col[y1]];
kc[col[y1]]++;
ans -= kc[row[x1]];
kr[row[x1]]++;
degR = row[x2], degC = col[y2];
ans += kc[degR];
kr[degR]--;
ans += kr[degC];
kc[degC]--;
row[x2] ^= pwer;
col[y2] ^= pwer;
ans -= kr[col[y1]];
kc[col[y1]]++;
ans -= kc[row[x1]];
kr[row[x1]]++;
cout<<ans<<endl;
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
6 |
Incorrect |
50 ms |
4604 KB |
Output isn't correct |
7 |
Incorrect |
38 ms |
4204 KB |
Output isn't correct |
8 |
Incorrect |
34 ms |
3692 KB |
Output isn't correct |
9 |
Incorrect |
35 ms |
3692 KB |
Output isn't correct |
10 |
Incorrect |
39 ms |
3692 KB |
Output isn't correct |
11 |
Incorrect |
592 ms |
30972 KB |
Output isn't correct |
12 |
Incorrect |
552 ms |
30968 KB |
Output isn't correct |
13 |
Incorrect |
602 ms |
31128 KB |
Output isn't correct |
14 |
Incorrect |
557 ms |
30844 KB |
Output isn't correct |
15 |
Incorrect |
547 ms |
30968 KB |
Output isn't correct |
16 |
Incorrect |
566 ms |
30844 KB |
Output isn't correct |
17 |
Incorrect |
582 ms |
31252 KB |
Output isn't correct |
18 |
Incorrect |
549 ms |
30972 KB |
Output isn't correct |
19 |
Incorrect |
564 ms |
30972 KB |
Output isn't correct |
20 |
Incorrect |
577 ms |
30972 KB |
Output isn't correct |