Submission #98559

#TimeUsernameProblemLanguageResultExecution timeMemory
98559polyfishTopovi (COCI15_topovi)C++14
120 / 120
1724 ms46072 KiB
//Pantyhose(black) + glasses = infinity #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << #x << " = " << x << '\n'; #define BP() cerr << "OK!\n"; #define PR(A, n) {cerr << #A << " = "; for (int64_t _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define PR0(A, n) {cerr << #A << " = "; for (int64_t _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define FILE_NAME "data" map<int64_t, int64_t> r, c, row, col; map<pair<int64_t, int64_t>, int64_t> mp; int64_t updRow(int64_t idx, int64_t v) { int64_t res = -col[r[idx]]; --row[r[idx]]; r[idx] ^= v; res += col[r[idx]]; ++row[r[idx]]; return res; } int64_t updCol(int64_t idx, int64_t v) { int64_t res = -row[c[idx]]; --col[c[idx]]; c[idx] ^= v; // debug(c[idx]); res += row[c[idx]]; ++col[c[idx]]; return res; } void solve() { int64_t n; int64_t k, nQueries; cin >> n >> k >> nQueries; row[0] = col[0] = n; int64_t res = n * n; for (int64_t i=1; i<=k; ++i) { int64_t x, y; cin >> x >> y; cin >> mp[{x, y}]; res += updRow(x, mp[{x, y}]); res += updCol(y, mp[{x, y}]); } while (nQueries--) { int64_t x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; mp[{x2, y2}] = mp[{x1, y1}]; res += updRow(x1, mp[{x1, y1}]); res += updCol(y1, mp[{x1, y1}]); res += updRow(x2, mp[{x2, y2}]); res += updCol(y2, mp[{x2, y2}]); mp[{x1, y1}] = 0; cout << n*n - res << '\n'; } } int main() { #ifdef GLASSES_GIRL freopen(FILE_NAME".in", "r", stdin); //freopen(FILE_NAME".out", "w", stdout); #endif ios::sync_with_stdio(0); cin.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...