133692025-01-07 17:22:36xxxRácsháló gráfcpp17Wrong answer 2/501ms524 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> v(n+1);
	int r = 0, l = 0;
	for(int i = 1; i <= k; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		if (x > y) {
			swap(x, y);
		}
		if (x/m == y/m) {
			l++, r++;
		} else if (x%m == y%m) {
			l++, r++;
		} else if (x%m < y%m) {
			l++;
		} else if (x%m > y%m) {
			r++;
		}
		cout << n + m - 2 - min(l, r) << endl;
	}
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms496 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms500 KiB
7Wrong answer0/21ms508 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms320 KiB
11Wrong answer0/21ms508 KiB
12Wrong answer0/21ms316 KiB
13Wrong answer0/31ms316 KiB
14Wrong answer0/31ms524 KiB
15Wrong answer0/31ms316 KiB
16Wrong answer0/31ms316 KiB
17Wrong answer0/31ms316 KiB
18Wrong answer0/31ms316 KiB
19Wrong answer0/31ms316 KiB
20Wrong answer0/31ms316 KiB
21Wrong answer0/31ms316 KiB
22Wrong answer0/31ms316 KiB