QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#425945 | #5528. Least Annoying Constructive Problem | Diu | WA | 0ms | 3948kb | C++14 | 580b | 2024-05-30 19:26:16 | 2024-05-30 19:26:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
void prt1(int u,int v){
u=(u%n+n)%n+1,v=(v%n+n)%n+1;
if(u>v)swap(u,v);
printf("%d %d\n",u,v);
}
void prt2(int u,int v){
if(u>v)swap(u,v);
printf("%d %d\n",u,v);
}
signed main(){
scanf("%d",&n);
if(n&1){
for(int i=0;i<=n/2;i++){
for(int j=1;j<=n/2;j++)prt1(j-i,n-j+1-i);
if(i==n/2)break;
for(int j=1;j<=n/2;j++)prt1(j-i,n-j-i);
}
}else{
for(int i=1;i<n;i++){
prt2(i,n);
for(int j=i+1,k=i-1,l=1;l<n/2;l++){
if(j==n)j=1;
if(k==0)k=n-1;
prt2(j,k);
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3948kb
input:
3
output:
1 2 2 3 1 3
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
4
output:
1 4 2 3 2 4 1 3 3 4 1 2
result:
ok Correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3944kb
input:
5
output:
1 2 3 5 2 5 3 4 1 5 2 4 1 4 2 3 4 5 1 3
result:
wrong answer Every consecutive n-1 edges have to form a tree, false for 7