#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define pf push_front
#define N 10005
#define M ll(998244353)
#define inf 1e9 + 1e9
using namespace std;
//using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef short int si;
typedef array <ll, 3> a3;
typedef array <ll, 4> a4;
//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll ans;
map <pair <ll, ll>, ll> a;
unordered_map <ll, ll> valx, valy, row, col;
set <ll> se, st;
void de(ll t, bool ob)
{
if (ob) valx[row[t]]--; else valy[col[t]]--;
}
void ad(ll t, bool ob)
{
if (ob) valx[row[t]]++; else valy[col[t]]++;
}
int main()
{
//freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n, k, p;
cin >> n >> k >> p;
for (ll i = 0; i < k; i++)
{
ll x, y, val;
cin >> x >> y >> val;
row[x] ^= val;
col[y] ^= val;
a[{x, y}] = val;
}
valy[0] = valx[0] = n;
for (auto it : col) {valy[0]--; valy[it.S]++;}
for (auto it : row) {valx[0]--; valx[it.S]++;}
for (auto it : valx) ans += it.S * valy[it.F];
for (; p > 0; p--)
{
ll x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
ll val = a[{x2, y2}] = a[{x1, y1}];
se.clear();
se.insert(row[x1]); se.insert(row[x2]); se.insert(col[y1]); se.insert(col[y2]);
for (auto it : se) ans -= valx[it] * valy[it];
de(x1, 1); de(x2, 1); de(y1, 0); de(y2, 0);
row[x1] ^= val; col[y1] ^= val; row[x2] ^= val; col[y2] ^= val;
st.clear();
st.insert(row[x1]); st.insert(row[x2]); st.insert(col[y1]); st.insert(col[y2]);
for (auto it : st) ans -= valx[it] * valy[it];
ad(x1, 1); ad(x2, 1); ad(y1, 0); ad(y2, 0);
for (auto it : se) ans += valx[it] * valy[it];
for (auto it : st) ans += valx[it] * valy[it];
cout << n * n - ans << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
68 ms |
5208 KB |
Output isn't correct |
7 |
Incorrect |
64 ms |
4904 KB |
Output isn't correct |
8 |
Incorrect |
37 ms |
3704 KB |
Output isn't correct |
9 |
Incorrect |
39 ms |
3704 KB |
Output isn't correct |
10 |
Incorrect |
40 ms |
3960 KB |
Output isn't correct |
11 |
Incorrect |
630 ms |
30716 KB |
Output isn't correct |
12 |
Incorrect |
610 ms |
30764 KB |
Output isn't correct |
13 |
Incorrect |
643 ms |
30844 KB |
Output isn't correct |
14 |
Incorrect |
628 ms |
30720 KB |
Output isn't correct |
15 |
Incorrect |
616 ms |
30844 KB |
Output isn't correct |
16 |
Incorrect |
682 ms |
30844 KB |
Output isn't correct |
17 |
Incorrect |
743 ms |
30844 KB |
Output isn't correct |
18 |
Incorrect |
647 ms |
30720 KB |
Output isn't correct |
19 |
Incorrect |
681 ms |
30716 KB |
Output isn't correct |
20 |
Incorrect |
777 ms |
30604 KB |
Output isn't correct |