Submission #98623

#TimeUsernameProblemLanguageResultExecution timeMemory
98623minhtung0404Topovi (COCI15_topovi)C++17
0 / 120
3 ms384 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, int v){ ans += 1LL * mp[0][val[i][num]] * mp[1][val[i][num]]; mp[i][val[i][num]]--; val[i][num] ^= x; mp[i][val[i][num]]++; ans -= 1LL * mp[0][val[i][num]] * mp[1][val[i][num]]; } int main(){ freopen("TOPOVI.inp", "r", stdin); freopen("TOPOVI.out", "w", stdout); cin >> n >> k >> p; ans = k * k; while (k--){ int r, c, x; cin >> r >> c >> x; add(0, r, x, 1); add(1, c, x, 1); ro[ii(r,c)] = 1; } 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, -1); add(1, c1, x, -1); add(0, r2, x, +1); add(1, c2, x, +1); cout << ans << "\n"; } }

Compilation message (stderr)

topovi.cpp: In function 'int main()':
topovi.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("TOPOVI.inp", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("TOPOVI.out", "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...