QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#175558#7178. Bishopsjsannemo#WA 2ms3664kbC++17866b2023-09-10 19:38:222023-09-10 19:38:22

Judging History

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

  • [2023-09-10 19:38:22]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3664kb
  • [2023-09-10 19:38:22]
  • 提交

answer

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

#define rep(i,f,t) for (int i = f; i < t; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define trav(a,x) for (auto& a : x)
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

vector<pii> solve(int R, int C) {
	vector<pii> res;
	for (int r = 1; r <= R; r += C) {
		rep(c,1,C+1) res.emplace_back(r, c);
	}
	int extra = (R - 1) % C;
	extra = 2 * extra - C;
	if (extra > 0) {
		rep(c,(C-extra)/2,(C+extra)/2) {
			res.emplace_back(R, c);
		}
	}
	return res;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int R, C;
	cin >> R >> C;

	vector<pii> X = solve(R, C);
	vector<pii> Y = solve(C, R);
	if (Y.size() > X.size()) {
		trav(it, Y) swap(it.first, it.second);
		X = Y;
	}
	cout << X.size() << endl;
	trav(it, X) {
		cout << it.first << " " << it.second << endl;
	}

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 5

output:

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

result:

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

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3664kb

input:

5 5

output:

8
1 1
1 2
1 3
1 4
1 5
5 1
5 2
5 3

result:

wrong answer Sum diagonals are not distinct