QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#174342#7178. Bishopsucup-team1766#WA 2ms3768kbC++231.1kb2023-09-10 06:37:232023-09-10 06:37:23

Judging History

你现在查看的是最新测评结果

  • [2023-09-10 06:37:23]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3768kb
  • [2023-09-10 06:37:23]
  • 提交

answer

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

int main() {
	int n, m; cin >> n >> m;
	bool flip = false;
	if (n > m) swap(n, m), flip =true;

	long long ans = 0;
	vector<array<int,2>> print;

	int i = 0, j = m-1;
	while (j - i >= n) {
		ans += 2*n;
		for (int k = 0; k < n; k++) {
			print.push_back({k, i});
			print.push_back({k, j});
		}
		i += n;
		j -= n;
	}

	if (i == j) {
		ans += n;
		for (int k = 0; k < n; k++) {
			print.push_back({k, i});
		}
	} else if (i < j) {
		ans += n;
		for (int k = 0; k < n; k++) {
			print.push_back({k, i});
		}
		i += n;
		goto label;
	} else {
label:
		int mid = (i+j)/2;
		int d = min(mid - i + n, j + n - mid);

		int temp = max(0, n - 2 * (n - d));
		for (int k = (n-temp)/2; k < (n+temp)/2; k++) {
			print.push_back({k, mid});
		}
		ans += temp;
		if ((i+j) % 2 && n % 2) {
			if (temp > 0) {
				mid++;
				while (temp > 1)
					mid++, temp-=2;
				print.push_back({n/2, mid});
				ans++;
			}
		}
	}

	cout << ans << '\n';
	for (auto [i,j] : print) {
		if (!flip)
			cout << i+1 << ' ' << j+1 << '\n';
		else
			cout << j+1 << ' ' << i+1 << '\n';
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3768kb

input:

2 5

output:

6
1 1
1 5
2 1
2 5
1 3
2 3

result:

ok n: 2, m: 5, bishops: 6

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3604kb

input:

5 5

output:

9
1 1
2 1
3 1
4 1
5 1
2 5
3 5
4 5
3 7

result:

wrong answer Integer parameter [name=y] equals to 7, violates the range [1, 5]