# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648716 | Adominator | Topovi (COCI15_topovi) | C++17 | 468 ms | 35880 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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--)
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
struct chash {
const uint64_t C=ll(2e18*acos(0))+71;
const int RANDOM=chrono::high_resolution_clock::now().time_since_epoch().count();
ll operator()(ll x) const {
return __builtin_bswap64((x^RANDOM)*C);
}
};
gp_hash_table<int, int, chash> 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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |