Submission #1144370

#TimeUsernameProblemLanguageResultExecution timeMemory
1144370THXuanTopovi (COCI15_topovi)C++20
60 / 120
2095 ms22344 KiB
#include <iostream> #include <vector> #include <algorithm> #include <bitset> #include <queue> #include <set> #include <map> #define INF 1e9 using namespace std; typedef long long ll; map<ll, ll>row, col, valrow, valcol; map<pair<ll, ll>, ll>v; ll calculate(int n) { ll ans = 0; for (auto u : valrow) { ans += u.second * (n - valcol[u.first]); } return ans; } void solve() { int n, k, p; cin >> n >> k >> p; for (int i = 1; i <= k; i++) { int r, c, x; cin >> r >> c >> x; v[{r, c}] = x; row[r] = row[r] ^ x; col[c] = col[c] ^ x; } valrow[0] = valcol[0] = n; for (auto u : row) { if (u.second == 0)continue; valrow[0]--; valrow[u.second]++; } for (auto u : col) { if (u.second == 0)continue; valcol[0]--; valcol[u.second]++; } while (p--) { int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; valrow[row[r1]]--; valrow[row[r2]]--; valcol[col[c1]]--; valcol[col[c2]]--; row[r1] = row[r1] ^ v[{r1, c1}]; col[c1] = col[c1] ^ v[{r1, c1}]; row[r2] = row[r2] ^ v[{r1, c1}]; col[c2] = col[c2] ^ v[{r1, c1}]; valrow[row[r1]]++; valrow[row[r2]]++; valcol[col[c1]]++; valcol[col[c2]]++; v[{r2, c2}] = v[{r1, c1}]; v[{r1, c1}] = 0; cout << calculate(n) << "\n"; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin>>t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...