답안 #154276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154276 2019-09-20T04:38:45 Z SeekingOblivion Topovi (COCI15_topovi) C++14
120 / 120
1484 ms 35956 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

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);
         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 149 ms 6008 KB Output is correct
7 Correct 123 ms 5308 KB Output is correct
8 Correct 99 ms 4456 KB Output is correct
9 Correct 98 ms 4572 KB Output is correct
10 Correct 109 ms 4856 KB Output is correct
11 Correct 1353 ms 35440 KB Output is correct
12 Correct 1430 ms 35664 KB Output is correct
13 Correct 1383 ms 35428 KB Output is correct
14 Correct 1407 ms 35956 KB Output is correct
15 Correct 1397 ms 35488 KB Output is correct
16 Correct 1396 ms 35468 KB Output is correct
17 Correct 1409 ms 35300 KB Output is correct
18 Correct 1434 ms 35256 KB Output is correct
19 Correct 1423 ms 35372 KB Output is correct
20 Correct 1484 ms 35384 KB Output is correct