Submission #154161

# Submission time Handle Problem Language Result Execution time Memory
154161 2019-09-18T16:38:55 Z SeekingOblivion Relativnost (COCI15_relativnost) C++14
0 / 140
4000 ms 47068 KB
//#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

relativnost.cpp: In function 'int main()':
relativnost.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);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
relativnost.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);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
relativnost.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);
         ~~~~~^~~~~~~~~~~~~~~
relativnost.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 time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Execution timed out 4072 ms 35736 KB Time limit exceeded
5 Execution timed out 4077 ms 45632 KB Time limit exceeded
6 Execution timed out 4017 ms 43228 KB Time limit exceeded
7 Execution timed out 4011 ms 37964 KB Time limit exceeded
8 Runtime error 1534 ms 33656 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
9 Execution timed out 4019 ms 47068 KB Time limit exceeded
10 Execution timed out 4094 ms 46040 KB Time limit exceeded