Submission #153933

#TimeUsernameProblemLanguageResultExecution timeMemory
153933Ruxandra985Topovi (COCI15_topovi)C++14
120 / 120
1750 ms33400 KiB
#include <cstdio> #include <set> #include <map> #include <algorithm> using namespace std; map <int,int> line,col,fl,fc; map <pair <int,int> , int > mp; long long sol = 0; int n; void add (int r , int c , int x){ sol = sol - (n - fc[line[r]]); sol = sol - (n - fl[col[c]]); if (line[r] == col[c]) sol++; fl[line[r]]--; fc[col[c]]--; line[r] = (line[r] ^ x); col[c] = (col[c] ^ x); /// n - cate col au val line[r] fl[line[r]]++; fc[col[c]]++; sol = sol + n - fc[line[r]]; sol = sol + n - fl[col[c]]; if (line[r] == col[c]) sol--; } int main() { FILE *fin = stdin; FILE *fout = stdout; int k,p,r,x,i,a,b,c,d; fscanf (fin,"%d%d%d",&n,&k,&p); fc[0] = fl[0] = n; for (i=1;i<=k;i++){ fscanf (fin,"%d%d%d",&r,&c,&x); mp[make_pair(r,c)] = x; add(r,c,x); } for (i=1;i<=p;i++){ fscanf (fin,"%d%d%d%d",&a,&b,&c,&d); x = mp[make_pair(a,b)]; mp.erase(make_pair(a,b)); add(a,b,x); add(c,d,x); mp[make_pair(c,d)] = x; fprintf (fout,"%lld\n",sol); } return 0; }

Compilation message (stderr)

topovi.cpp: In function 'int main()':
topovi.cpp:49:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d%d%d",&n,&k,&p);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:52:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d%d%d",&r,&c,&x);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:57:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d%d%d%d",&a,&b,&c,&d);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...