QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#84167#5528. Least Annoying Constructive Problemsinsop90WA 1ms3692kbC++14689b2023-03-05 20:43:222023-03-05 20:43:23

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-05 20:43:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3692kb
  • [2023-03-05 20:43:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n;
int rev(int x) {
	if(x <= 0) return x + n;
	if(x > n) return x - n;
	return x;
}
int main() {
	scanf("%d", &n);
	if(n & 1) {
		for(int i = 1;i <= n;i++) {
			for(int j = 1;j <= n / 2;j++) {
				int u = rev(i - j + 1), v = rev(i + j);
				if(u > v) swap(u, v);
				printf("%d %d\n", u, v);
			}
		}
	}
	else {
		int cnt = 0, now = 0;
		n --;
		for(int i = 1;i <= n;i++) {
			for(int j = 1;j <= n / 2;j++) {
				int u = rev(i - j + 1), v	 = rev(i + j);
				cnt ++;
				if(u > v) swap(u, v);
				printf("%d %d\n", u, v);
				if(j == n / 2) cnt = 0, now ++, printf("%d %d\n", i + n / 2, n + 1);
			}
		}
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3520kb

input:

3

output:

1 2
2 3
1 3

result:

ok Correct

Test #2:

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

input:

4

output:

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

result:

wrong answer Integer 4 violates the range [5, 4]