Submission #154276

#TimeUsernameProblemLanguageResultExecution timeMemory
154276SeekingOblivionTopovi (COCI15_topovi)C++14
120 / 120
1484 ms35956 KiB
//#include<fstream>
#include<map>
#include<cstdio>
//#define fin cin
//#define fout cout
using namespace std;
//ifstream fin("date.in");
//ofstream fout("date.out");
int i,j,n,k,p,s;
long long sol;
map<int,int> xori,xorj,fi,fj;
map<pair<int,int>,int> r;
 
void solve(int i,int j,int p)
{
    sol-=n-fj[xori[i]];
    sol-=n-fi[xorj[j]];
    fi[xori[i]]--;xori[i]^=p;fi[xori[i]]++;
    fj[xorj[j]]--;xorj[j]^=p;fj[xorj[j]]++;
    sol+=n-fj[xori[i]];
    sol+=n-fi[xorj[j]];
    r[make_pair(i,j)]^=p;
}
 
int main()
{
    scanf("%d %d %d",&n,&k,&p);
    fi[0]=fj[0]=n;
    for(;k--;)
    {
        scanf("%d %d %d",&i,&j,&s);
        solve(i,j,s);
    }
    for(;p--;)
    {
        scanf("%d %d",&i,&j);
        s=r[make_pair(i,j)];
        solve(i,j,s);
        scanf("%d %d",&i,&j);
        solve(i,j,s);
        printf("%lld\n",sol);
    }
    return 0;
}

Compilation message (stderr)

topovi.cpp: In function 'int main()':
topovi.cpp:27:10: 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:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d",&i,&j,&s);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
topovi.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&i,&j);
         ~~~~~^~~~~~~~~~~~~~~
topovi.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&i,&j);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...