/***************************************************************************/
/********************** LANG TU HAO HOA **********************************/
/***************************************************************************/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pii pair<int, int>
#define sz(x) ((int) x.size())
#define PB push_back
#define PF push_front
#define MP make_pair
#define ll long long
#define F first
#define S second
#define maxc 1000000007
#define MOD 1000000007
#define base 107
#define eps 1e-6
#define pi acos(-1)
#define N 100005
#define task ""
#define remain(x) ((x > MOD) ? (x - MOD) : x)
using namespace std;
int n, p, k;
ll res;
map <int, int> r, c, demC, demR;
map <pii, int> dd;
void Calc(int x, int y, int fl)
{
res += fl * demC[r[x]];
res += fl * demR[c[y]];
if (r[x] == c[y]) res -= fl;
}
void Upd(int x, int y, int w)
{
Calc(x, y, -1);
demR[r[x]]--, demC[c[y]]--;
r[x] ^= w, c[y] ^= w;
demR[r[x]]++, demC[c[y]]++;
Calc(x, y, 1);
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
//freopen(task".inp", "r", stdin);
//freopen(task".out", "w", stdout);
cin >> n >> p >> k;
res = 1ll*n*n;
FOR(i, 1, p)
{
int u, v, w;
cin >> u >> v >> w;
dd[MP(u, v)] = w;
}
demR[0] = n;
demC[0] = n;
FOR(i, 1, k)
{
int x, y, u, v;
cin >> x >> y >> u >> v;
int w = dd[MP(x, y)];
dd[MP(x, y)] = 0;
dd[MP(u, v)] = w;
Upd(x, y, w);
Upd(u, v, w);
cout << 1ll*n*n - res << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
159 ms |
5076 KB |
Output isn't correct |
7 |
Incorrect |
95 ms |
4100 KB |
Output isn't correct |
8 |
Incorrect |
76 ms |
3448 KB |
Output isn't correct |
9 |
Incorrect |
82 ms |
3448 KB |
Output isn't correct |
10 |
Incorrect |
96 ms |
3832 KB |
Output isn't correct |
11 |
Incorrect |
1166 ms |
28692 KB |
Output isn't correct |
12 |
Incorrect |
1230 ms |
28816 KB |
Output isn't correct |
13 |
Incorrect |
1264 ms |
28764 KB |
Output isn't correct |
14 |
Incorrect |
1285 ms |
28764 KB |
Output isn't correct |
15 |
Incorrect |
1365 ms |
28772 KB |
Output isn't correct |
16 |
Incorrect |
1285 ms |
28868 KB |
Output isn't correct |
17 |
Incorrect |
1259 ms |
28784 KB |
Output isn't correct |
18 |
Incorrect |
1229 ms |
28752 KB |
Output isn't correct |
19 |
Incorrect |
1216 ms |
28936 KB |
Output isn't correct |
20 |
Incorrect |
1119 ms |
28764 KB |
Output isn't correct |