답안 #210064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210064 2020-03-16T13:39:47 Z ZwariowanyMarcin Topovi (COCI15_topovi) C++14
120 / 120
1151 ms 39544 KB
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep2(i, j, n) for (LL i = j; i <= n; ++i)
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define boost cin.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 1e5 + 10101;

map <pair<int, int>, int> mapa;
map <int, int> row, col;
map <int, int> cnt1, cnt2;

int n, k, p, a, b, c, d;
LL ans;

void upd1(int r, int x) {
	ans -= cnt2[row[r]];
	cnt1[row[r]]--;
	row[r] ^= x;
	ans += cnt2[row[r]];
	cnt1[row[r]]++;
}

void upd2(int c, int x) {
	ans -= cnt1[col[c]];
	cnt2[col[c]]--;
	col[c] ^= x;
	ans += cnt1[col[c]];
	cnt2[col[c]]++;
}

int main() {
	scanf ("%d%d%d", &n, &k, &p);
	ans = (LL) n * n;
	cnt1[0] = n;
	cnt2[0] = n;
	rep(i, 1, k) {
		scanf ("%d%d%d", &a, &b, &c);
		mapa[{a, b}] = c;
		upd1(a, c);
		upd2(b, c);
	}
	while (p--) {
		scanf ("%d%d%d%d", &a, &b, &c, &d);
		int e = mapa[{a, b}];
		mapa[{c, d}] = e;
		upd1(a, e);
		upd2(b, e);
		upd1(c, e);
		upd2(d, e);
		printf ("%lld\n", (LL) n * n - ans);
	}
		
	return 0;
}

Compilation message

topovi.cpp: In function 'int main()':
topovi.cpp:44:8: 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:49:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d%d%d", &a, &b, &c);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:55:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d%d%d%d", &a, &b, &c, &d);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 125 ms 6112 KB Output is correct
7 Correct 102 ms 5368 KB Output is correct
8 Correct 81 ms 4472 KB Output is correct
9 Correct 83 ms 4600 KB Output is correct
10 Correct 100 ms 4728 KB Output is correct
11 Correct 1151 ms 39488 KB Output is correct
12 Correct 1132 ms 39512 KB Output is correct
13 Correct 1112 ms 39416 KB Output is correct
14 Correct 1143 ms 39416 KB Output is correct
15 Correct 1149 ms 39416 KB Output is correct
16 Correct 1131 ms 39416 KB Output is correct
17 Correct 1136 ms 39432 KB Output is correct
18 Correct 1136 ms 39424 KB Output is correct
19 Correct 1148 ms 39416 KB Output is correct
20 Correct 1138 ms 39544 KB Output is correct