Submission #98624

#TimeUsernameProblemLanguageResultExecution timeMemory
98624minhtung0404Topovi (COCI15_topovi)C++17
60 / 120
2103 ms33768 KiB
#include<bits/stdc++.h> const int N = 1e5 + 5; using namespace std; typedef pair <int, int> ii; map <int, int> mp[2], val[2]; map <ii, int> ro; int n, k, p; long long ans; void add(int i, int num, int x){ ans += 1LL * mp[0][val[i][num]] * mp[1][val[i][num]]; mp[i][val[i][num]]--; ans -= 1LL * mp[0][val[i][num]] * mp[1][val[i][num]]; val[i][num] ^= x; ans += 1LL * mp[0][val[i][num]] * mp[1][val[i][num]]; mp[i][val[i][num]]++; ans -= 1LL * mp[0][val[i][num]] * mp[1][val[i][num]]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k >> p; mp[0][0] = mp[1][0] = n; while (k--){ int r, c, x; cin >> r >> c >> x; add(0, r, x); add(1, c, x); ro[ii(r,c)] = x; } while (p--){ int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; int x = ro[ii(r1,c1)]; ro[ii(r1,c1)] = 0; ro[ii(r2,c2)] = x; add(0, r1, x); add(1, c1, x); add(0, r2, x); add(1, c2, x); cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...