제출 #210064

#제출 시각아이디문제언어결과실행 시간메모리
210064ZwariowanyMarcinTopovi (COCI15_topovi)C++14
120 / 120
1151 ms39544 KiB
#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;
}

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

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);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...