# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98654 | HellAngel | Topovi (COCI15_topovi) | C++14 | 2053 ms | 58940 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.
#include <bits/stdc++.h>
#define int long long
#define y1 concac
using namespace std;
map<int, int> row, col,cntrow, cntcol, valrow, valcol;
map<pair<int, int>, int> hihi;
int n, k, p;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("test.inp", "r", stdin);
//freopen("test.out", "w", stdout);
cin >> n >> k >> p;
for(int i = 1; i <= k; i++)
{
int u, v, c;
cin >> u >> v >> c;
row[u] ^= c;
col[v] ^= c;
cntrow[u]++;
cntcol[v]++;
hihi[{u, v}] = c;
}
valrow[0] = n - cntrow.size();
valcol[0] = n - cntcol.size();
int ans = (n - cntrow.size()) * (n - cntcol.size());
for(auto i: row)
{
int gau = i.first;
int meo = i.second;
valrow[i.second]++;
if(valcol.find(i.second) != valcol.end()) ans += valcol[i.second];
}
for(auto i: col)
{
int gau = i.first;
int meo = i.second;
valcol[i.second]++;
if(valrow.find(i.second) != valrow.end()) ans += valrow[i.second];
}
for(int i = 1; i <= p; i++)
{
int x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
int val = hihi[{x1, y1}];
hihi.erase(hihi.find({x1, y1}));
hihi[{x2, y2}] = val;
int oldrow = row[x1];
cntrow[x1]--;
valrow[oldrow]--;
ans -= valcol[oldrow];
row[x1] ^= val;
int newrow = oldrow ^ val;
valrow[newrow]++;
ans += valcol[newrow];
oldrow = row[x2];
cntrow[x2]++;
valrow[oldrow]--;
ans -= valcol[oldrow];
newrow = oldrow ^ val;
row[x2] ^= val;
valrow[newrow]++;
ans += valcol[newrow];
int oldcol = col[y1];
cntcol[y1]--;
valcol[oldcol]--;
ans -= valrow[oldcol];
col[y1] ^= val;
int newcol = oldcol ^ val;
valcol[newcol]++;
ans += valrow[newcol];
oldcol = col[y2];
cntcol[y2]++;
valcol[oldcol]--;
ans -= valrow[oldcol];
newcol = oldcol ^= val;
col[y2] ^= val;
valcol[newcol]++;
ans += valrow[newcol];
cout << n * n - ans << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |