Submission #98654

#TimeUsernameProblemLanguageResultExecution timeMemory
98654HellAngelTopovi (COCI15_topovi)C++14
90 / 120
2053 ms58940 KiB
#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)

topovi.cpp: In function 'int32_t main()':
topovi.cpp:30:13: warning: unused variable 'gau' [-Wunused-variable]
         int gau = i.first;
             ^~~
topovi.cpp:31:13: warning: unused variable 'meo' [-Wunused-variable]
         int meo = i.second;
             ^~~
topovi.cpp:37:13: warning: unused variable 'gau' [-Wunused-variable]
         int gau = i.first;
             ^~~
topovi.cpp:38:13: warning: unused variable 'meo' [-Wunused-variable]
         int meo = i.second;
             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...