답안 #164101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164101 2019-11-17T13:00:20 Z beso123 Topovi (COCI15_topovi) C++14
30 / 120
1994 ms 45392 KB
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
map<int,int> xorr,xorc;
map<int,int> cntr,cntc;
map<pair<int,int>,int> rook;
int ans = 0;
int n,k,p;
void add(int r,int c,int x){
    rook[{r,c}] ^= x;
    ans -= n-cntc[xorr[r]];
    ans -= n-cntr[xorc[c]];
    if (xorr[r] != xorc[c]) ans++;
    cntc[xorc[c]]--;
    cntr[xorr[r]]--;
    xorr[r] ^= x;
    xorc[c] ^= x;
    cntc[xorc[c]]++;
    cntr[xorr[r]]++;
    ans += n-cntc[xorr[r]];
    ans += n-cntr[xorc[c]];
    if (xorr[r] != xorc[c]) ans--;
}
main(){
scanf("%I64d%I64d%I64d",&n,&k,&p);
    cntr[0] = n;
    cntc[0] = n;
    rep(i,k){
    	int r,c,x;
    	scanf("%I64d%I64d%I64d",&r,&c,&x);
    	add(r,c,x);
    }
    while(p--){
    	int r1,c1,r2,c2;
    	scanf("%I64d%I64d%I64d%I64d",&r1,&c1,&r2,&c2);
        int x = rook[{r1,c1}];
    	add(r1,c1,x);
        add(r2,c2,x);
    	printf("%I64d\n",ans);
    }
    return 0;
}

Compilation message

topovi.cpp:31:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
topovi.cpp: In function 'int main()':
topovi.cpp:32:33: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 scanf("%I64d%I64d%I64d",&n,&k,&p);
                         ~~      ^
topovi.cpp:32:33: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
topovi.cpp:32:33: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
topovi.cpp:37:38: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
      scanf("%I64d%I64d%I64d",&r,&c,&x);
                              ~~      ^
topovi.cpp:37:38: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
topovi.cpp:37:38: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
topovi.cpp:42:50: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
      scanf("%I64d%I64d%I64d%I64d",&r1,&c1,&r2,&c2);
                                   ~~~            ^
topovi.cpp:42:50: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
topovi.cpp:42:50: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
topovi.cpp:42:50: warning: format '%d' expects argument of type 'int*', but argument 5 has type 'long long int*' [-Wformat=]
topovi.cpp:46:26: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
      printf("%I64d\n",ans);
                          ^
topovi.cpp:32:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%I64d%I64d%I64d",&n,&k,&p);
 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:37:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%I64d%I64d%I64d",&r,&c,&x);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:42:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%I64d%I64d%I64d%I64d",&r1,&c1,&r2,&c2);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Incorrect 239 ms 7788 KB Output isn't correct
7 Incorrect 188 ms 6648 KB Output isn't correct
8 Incorrect 188 ms 5748 KB Output isn't correct
9 Incorrect 153 ms 5724 KB Output isn't correct
10 Incorrect 167 ms 6028 KB Output isn't correct
11 Incorrect 1985 ms 45236 KB Output isn't correct
12 Incorrect 1994 ms 45244 KB Output isn't correct
13 Incorrect 1958 ms 45392 KB Output isn't correct
14 Incorrect 1989 ms 45272 KB Output isn't correct
15 Incorrect 1966 ms 45340 KB Output isn't correct
16 Incorrect 1935 ms 45348 KB Output isn't correct
17 Incorrect 1947 ms 45156 KB Output isn't correct
18 Incorrect 1944 ms 45156 KB Output isn't correct
19 Incorrect 1944 ms 45172 KB Output isn't correct
20 Incorrect 1955 ms 45324 KB Output isn't correct