QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#578454 | #5528. Least Annoying Constructive Problem | HuTao | WA | 0ms | 3948kb | C++14 | 968b | 2024-09-20 19:19:37 | 2024-09-20 19:19:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int M = 1 << 18 | 5;
int n;
pair<int, int> e[M];
int main()
{
scanf("%d", &n);
int c = 0;
if(n & 1)
{
for(int i = 1; i <= n / 2; i ++ ) e[ ++ c] = make_pair(i + 0, n + 1 - i);
for(int i = 1; i <= n / 2; i ++ ) e[ ++ c] = make_pair(i + 1, n + 1 - i);
}
else
{
for(int i = 1; i < n / 2; i ++ ) e[ ++ c] = make_pair(i, n + 0 - i);
for(int i = 1; i <= n / 2; i ++ ) e[ ++ c] = make_pair(i, n + 1 - i);
}
for(int i = n; i <= n * (n - 1) / 2; i ++ )
{
e[i] = e[i - n + 1];
if(e[i].first <= n) e[i].first = e[i].first % n + 1;
if(e[i].second <= n) e[i].second = e[i].second % n + 1;
}
for(int i = 1; i <= n * (n - 1) / 2; i ++ )
{
if(e[i].first > e[i].second) swap(e[i].first, e[i].second);
printf("%d %d\n", e[i].first, e[i].second);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3948kb
input:
3
output:
1 3 2 3 1 2
result:
ok Correct
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3792kb
input:
4
output:
1 3 1 4 2 3 2 4 1 2 3 4
result:
wrong answer Every consecutive n-1 edges have to form a tree, false for 5