Submission #648717

#TimeUsernameProblemLanguageResultExecution timeMemory
648717AdominatorTopovi (COCI15_topovi)C++17
120 / 120
1323 ms33956 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ar array #define vo vector #define pb push_back #define all(x) begin(x), end(x) #define sz(x) (ll)(x).size() #define rep(i, a, b) for(ll i=(a); i<(b); i++) #define repd(i, a, b) for(ll i=(a); i>=(b); i--) map<int, int> rcnt, ccnt, col, row; map<ar<int, 2>, int> val; int n, k, p; ll ans; void move(int r, int c, int x) { ans-=n-rcnt[col[c]]; ans-=n-ccnt[row[r]]; if(col[c]^row[r]) ans++; --rcnt[row[r]]; row[r]^=x; ++rcnt[row[r]]; --ccnt[col[c]]; col[c]^=x; ++ccnt[col[c]]; ans+=n-rcnt[col[c]]; ans+=n-ccnt[row[r]]; if(col[c]^row[r]) ans--; val[{r, c}]^=x; } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> k >> p; ccnt[0]=rcnt[0]=n; rep(i, 0, k) { int r, c, x; cin >> r >> c >> x; move(r, c, x); } rep(i, 0, p) { int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; int tmp=val[{r1, c1}]; move(r1, c1, tmp); move(r2, c2, tmp); cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...