제출 #82816

#제출 시각아이디문제언어결과실행 시간메모리
82816xiaowuc1Topovi (COCI15_topovi)C++14
90 / 120
1483 ms66560 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

map<int, int> rowXOR;
map<int, int> colXOR;
map<int, int> rowF, colF;
map<pii, int> loc;

void change(map<int, int>& m, int k, int v) {
	m[k] += v;
	if(m[k] == 0) m.erase(k);
}

ll ret;

void flip(int x, int y, int v) {
	ret += colF[rowXOR[x]];
	change(rowF, rowXOR[x], -1);
	rowXOR[x] ^= v;
	change(rowF, rowXOR[x], 1);
	ret -= colF[rowXOR[x]];

	ret += rowF[colXOR[y]];
	change(colF, colXOR[y], -1);
	colXOR[y] ^= v;
	change(colF, colXOR[y], 1);
	ret -= rowF[colXOR[y]];
}


int main() {
	int n, k, p;
	scanf("%d%d%d", &n, &k, &p);
	rowF[0] = n;
	colF[0] = n;
	while(k--) {
		int x, y, v;
		scanf("%d%d%d", &x, &y, &v);
		loc[{x, y}] = v;
		flip(x, y, v);
	}
	while(p--) {
		int xa, ya, xb, yb;
		scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
		int v = loc[{xa, ya}];
		flip(xa, ya, v);
		flip(xb, yb, v);
		loc.erase({xa, ya});
		loc[{xb, yb}] = v;
		printf("%lld\n", ret);
	}
}

컴파일 시 표준 에러 (stderr) 메시지

topovi.cpp: In function 'int main()':
topovi.cpp:37:7: 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:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &x, &y, &v);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...