# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98709 | Tieuphong | Topovi (COCI15_topovi) | C++11 | 1365 ms | 28936 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/***************************************************************************/
/********************** 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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |