Submission #465389

#TimeUsernameProblemLanguageResultExecution timeMemory
465389JovanBTopovi (COCI15_topovi)C++17
120 / 120
1135 ms39516 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; map <int, int> row; map <int, int> col; map <int, int> crow; map <int, int> ccol; map <pair <int, int>, int> pw; ll tr; void uradi(int i, int j, int p){ crow[row[i]]--; tr -= ccol[row[i]]; row[i] ^= p; tr += ccol[row[i]]; crow[row[i]]++; ccol[col[j]]--; tr -= crow[col[j]]; col[j] ^= p; tr += crow[col[j]]; ccol[col[j]]++; pw[{i, j}] = p; } int main(){ ios_base::sync_with_stdio(false), cin.tie(0); cout.precision(10); cout << fixed; ll n; int k, p; cin >> n >> k >> p; ccol[0] = crow[0] = n; tr = n*n; while(k--){ int i, j, pww; cin >> i >> j >> pww; uradi(i, j, pww); } while(p--){ int i, j; cin >> i >> j; int pww = pw[{i, j}]; uradi(i, j, pww); pw[{i, j}] = 0; cin >> i >> j; uradi(i, j, pww); cout << n*n - tr << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...