QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#561696#5528. Least Annoying Constructive Problem251SecWA 0ms3872kbC++14598b2024-09-13 08:51:032024-09-13 08:51:04

Judging History

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

  • [2024-09-13 08:51:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-09-13 08:51:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int Nxt(int i) { return i % n + 1; }
int Pre(int i) { return (i - 2 + n) % n + 1; }
int main() {
	scanf("%d", &n);
	if (n & 1) {
		for (int i = 1; i <= n; i++) {
			for (int a = i, b = Nxt(i); a != b; a = Pre(a), b = Nxt(b)) {
				printf("%d %d\n", min(a, b), max(a, b));
			}
		}
	}
	else {
		n--;
		for (int i = 1; i <= n; i++) {
			for (int a = i, b = Nxt(i); a != b; a = Pre(a), b = Nxt(b)) {
				printf("%d %d\n", min(a, b), max(a, b));
			}
			printf("%d %d\n", i, n + 1);
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3

output:

1 2
2 3
1 3

result:

ok Correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

4

output:

1 2
1 4
2 3
2 4
1 3
3 4

result:

ok Correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

5

output:

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

result:

ok Correct

Test #4:

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

input:

6

output:

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

result:

wrong answer Every consecutive n-1 edges have to form a tree, false for 2