Submission #230565

#TimeUsernameProblemLanguageResultExecution timeMemory
230565ParsaAlizadehTopovi (COCI15_topovi)C++17
120 / 120
1286 ms27784 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include <cstdio> #include <map> using namespace std; int n, k, q, r1, c1, r2, c2, x; long long ans; map<int, int> row, col, cntr, cntc; map<pair<int, int>, int> mp; inline void func(int r, int c, int val) { ans -= n - cntc[row[r]]; ans -= n - cntr[col[c]]; if (row[r] != col[c]) ans++; cntr[row[r]]--; row[r] ^= val; cntr[row[r]]++; cntc[col[c]]--; col[c] ^= val; cntc[col[c]]++; ans += n - cntc[row[r]]; ans += n - cntr[col[c]]; if (row[r] != col[c]) ans--; } int main() { scanf("%d %d %d", &n, &k, &q); cntr[0] = n; cntc[0] = n; for (int i = 0; i < k; i++) { scanf("%d %d %d", &r1, &c1, &x); mp[{r1, c1}] = x; func(r1, c1, x); } while (q--) { scanf("%d %d %d %d", &r1, &c1, &r2, &c2); x = mp[{r1, c1}]; mp.erase({r1, c1}); mp[{r2, c2}] = x; func(r1, c1, x); func(r2, c2, x); printf("%lld\n", ans); } return 0; }

Compilation message (stderr)

topovi.cpp: In function 'int main()':
topovi.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &k, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &r1, &c1, &x);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...