답안 #82816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82816 2018-11-01T20:43:30 Z xiaowuc1 Topovi (COCI15_topovi) C++14
90 / 120
1483 ms 66560 KB
#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);
	}
}

Compilation message

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);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 500 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 142 ms 4996 KB Output is correct
7 Correct 117 ms 5660 KB Output is correct
8 Correct 99 ms 5660 KB Output is correct
9 Correct 98 ms 6128 KB Output is correct
10 Correct 101 ms 6576 KB Output is correct
11 Correct 1417 ms 36484 KB Output is correct
12 Correct 1452 ms 42424 KB Output is correct
13 Correct 1370 ms 48548 KB Output is correct
14 Correct 1358 ms 54396 KB Output is correct
15 Correct 1369 ms 60504 KB Output is correct
16 Runtime error 1418 ms 66364 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
17 Runtime error 1419 ms 66560 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
18 Runtime error 1405 ms 66560 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
19 Runtime error 1429 ms 66560 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
20 Runtime error 1483 ms 66560 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.