QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#202314#7178. Bishops08kevinWA 16ms8832kbC++171.8kb2023-10-05 21:59:162023-10-05 21:59:16

Judging History

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

  • [2023-10-05 21:59:16]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:8832kb
  • [2023-10-05 21:59:16]
  • 提交

answer

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

typedef long long ll;

const ll mod = 998244353;

struct node {
	ll x, y;
} ans[400100];

ll n, m, t;

inline void work() {
	printf("%lld\n", t);
	for (ll i = 1; i <= t; i++) {
		printf("%lld %lld\n", ans[i].x, ans[i].y);
	}
	return;
}

int main() {
	scanf("%lld%lld", &n, &m);
	if (n == 1 && m == 1) {
		printf("1\n");
		printf("1 1\n");
		return 0;
	}
	if (n == m) {
		for (ll i = 1; i < n; i++) {
			t++;
			ans[t].x = 1;
			ans[t].y = i;
			t++;
			ans[t].x = n;
			ans[t].y = i;
		}
		work();
		return 0;
	}
	if (n < m) {
		for (ll i = 1; i <= n; i++) {
			t++;
			ans[t].x = i;
			ans[t].y = 1;
			t++;
			ans[t].x = i;
			ans[t].y = m;
		}
		if (n & 1) {
			for (ll i = 1; i <= m - n - 1; i++) {
				t++;
				ans[t].x = (n + 1) / 2;
				ans[t].y = i + (n + 1) / 2;
			}
		} else {
			if (m & 1) {
				for (ll i = n / 2 + 2; i <= m - n / 2 - 1; i += 2) {
					t++;
					ans[t].x = n / 2;
					ans[t].y = i;
					t++;
					ans[t].x = n / 2 + 1;
					ans[t].y = i;
				}
			} else {
				for (ll i = n / 2 + 2; i >= m - n / 2 - 1; i++) {
					t++;
					ans[t].x = n / 2;
					ans[t].y = i;
				}
			}
		}
	} else {
		for (ll i = 1; i <= m; i++) {
			t++;
			ans[t].x = 1;
			ans[t].y = i;
			t++;
			ans[t].x = n;
			ans[t].y = i;
		}
		if (m & 1) {
			for (ll i = 1; i <= n - m - 1; i++) {
				t++;
				ans[t].x = i + (m + 1) / 2;
				ans[t].y = (m + 1) / 2;
			}
		} else {
			if (n & 1) {
				for (ll i = m / 2 + 2; i <= n - m / 2 - 1; i += 2) {
					t++;
					ans[t].x = i;
					ans[t].y = m / 2;
					t++;
					ans[t].x = i;
					ans[t].y = m / 2 + 1;
				}
			} else {
				for (ll i = m / 2 + 2; i >= n - m / 2 - 1; i++) {
					t++;
					ans[t].x = i;
					ans[t].y = m / 2;
				}
			}
		}
	}
	work(); 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3972kb

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: 0
Accepted
time: 0ms
memory: 3972kb

input:

5 5

output:

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

result:

ok n: 5, m: 5, bishops: 8

Test #3:

score: 0
Accepted
time: 12ms
memory: 8832kb

input:

100000 100000

output:

199998
1 1
100000 1
1 2
100000 2
1 3
100000 3
1 4
100000 4
1 5
100000 5
1 6
100000 6
1 7
100000 7
1 8
100000 8
1 9
100000 9
1 10
100000 10
1 11
100000 11
1 12
100000 12
1 13
100000 13
1 14
100000 14
1 15
100000 15
1 16
100000 16
1 17
100000 17
1 18
100000 18
1 19
100000 19
1 20
100000 20
1 21
100000...

result:

ok n: 100000, m: 100000, bishops: 199998

Test #4:

score: 0
Accepted
time: 16ms
memory: 8032kb

input:

100000 99999

output:

199998
1 1
100000 1
1 2
100000 2
1 3
100000 3
1 4
100000 4
1 5
100000 5
1 6
100000 6
1 7
100000 7
1 8
100000 8
1 9
100000 9
1 10
100000 10
1 11
100000 11
1 12
100000 12
1 13
100000 13
1 14
100000 14
1 15
100000 15
1 16
100000 16
1 17
100000 17
1 18
100000 18
1 19
100000 19
1 20
100000 20
1 21
100000...

result:

ok n: 100000, m: 99999, bishops: 199998

Test #5:

score: -100
Wrong Answer
time: 9ms
memory: 7132kb

input:

100000 50000

output:

100000
1 1
100000 1
1 2
100000 2
1 3
100000 3
1 4
100000 4
1 5
100000 5
1 6
100000 6
1 7
100000 7
1 8
100000 8
1 9
100000 9
1 10
100000 10
1 11
100000 11
1 12
100000 12
1 13
100000 13
1 14
100000 14
1 15
100000 15
1 16
100000 16
1 17
100000 17
1 18
100000 18
1 19
100000 19
1 20
100000 20
1 21
100000...

result:

wrong answer Participant's answer is not optimal (100000 < 149998)