Submission #78785

#TimeUsernameProblemLanguageResultExecution timeMemory
78785ekremTopovi (COCI15_topovi)C++98
120 / 120
1940 ms46492 KiB
#include <bits/stdc++.h> #define st first #define nd second #define mp make_pair #define pb push_back #define N 1000005 using namespace std; typedef long long ll; typedef pair < int , int > ii; int n, k, p; ll ans; map < int , int > r, c, sr, sc; map < ii , int > ne; map < int , int > :: iterator it; void ekle(int x, int y, int z){ ne[mp(x, y)] = z; ans -= 1ll * sc[r[x]] * n - 1ll * sc[r[x]] * sr[r[x]]; sr[r[x]]--; ans += 1ll * sc[r[x]] * n - 1ll * sc[r[x]] * sr[r[x]]; r[x] = r[x]^z; sr[r[x]]++; ans -= 1ll * sc[r[x]]; ans -= 1ll * sc[c[y]] * n - 1ll * sc[c[y]] * sr[c[y]]; sc[c[y]]--; ans += 1ll * sc[c[y]] * n - 1ll * sc[c[y]] * sr[c[y]]; c[y] = c[y]^z; sc[c[y]]++; ans += 1ll * n - 1ll * sr[c[y]]; } int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); scanf("%d %d %d",&n ,&k, &p); sr[0] = n; sc[0] = n; for(int i = 1; i <= k; i++){ int x, y, z; scanf("%d %d %d",&x ,&y ,&z); ekle(x, y, z); } for(int i = 1; i <= p; i++){ int x, y, z, k; scanf("%d %d %d %d",&x ,&y ,&z ,&k); int xx = ne[mp(x, y)]; ekle(x, y, xx); ekle(z, k, xx); ne[mp(z, k)] = xx; printf("%lld\n", ans); } return 0; }

Compilation message (stderr)

topovi.cpp: In function 'int main()':
topovi.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n ,&k, &p);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&x ,&y ,&z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d",&x ,&y ,&z ,&k);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...