QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#80518 | #5528. Least Annoying Constructive Problem | zhouhuanyi | WA | 2ms | 3500kb | C++14 | 1.2kb | 2023-02-24 09:26:25 | 2023-02-24 09:26:26 |
Judging History
answer
#include<iostream>
#include<cstdio>
#define N 10000
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
struct reads
{
int x,y;
};
reads tong[N+1];
int n,length,num,cnt;
int main()
{
n=read();
if (n&1)
{
for (int i=1;i<=((n+1)>>1);++i)
{
for (int j=1;j<=(n>>1);++j) tong[++length]=(reads){(i-1)%n+1,(i-1+j)%n+1};
if (i!=((n+1)>>1))
{
for (int j=1;j<=(n>>1);++j) tong[++length]=(reads){(i+((n+1)>>1)-1)%n+1,(i+((n+1)>>1)-1+j)%n+1};
}
}
}
else
{
n--;
for (int i=1;i<=((n+1)>>1);++i)
{
for (int j=1;j<=(n>>1);++j)
{
tong[++length]=(reads){(i-1)%n+1,(i-1+j)%n+1},++cnt;
if (cnt%(n>>1)==0) tong[++length]=(reads){++num,n+1};
}
if (i!=((n+1)>>1))
{
for (int j=1;j<=(n>>1);++j)
{
tong[++length]=(reads){(i+((n+1)>>1)-1)%n+1,(i+((n+1)>>1)-1+j)%n+1},++cnt;
if (cnt%(n>>1)==0) tong[++length]=(reads){++num,n+1};
}
}
}
}
for (int i=1;i<=length;++i) printf("%d %d\n",min(tong[i].x,tong[i].y),max(tong[i].x,tong[i].y));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3452kb
input:
3
output:
1 2 1 3 2 3
result:
ok Correct
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3500kb
input:
4
output:
1 2 1 4 1 3 2 4 2 3 3 4
result:
wrong answer Every consecutive n-1 edges have to form a tree, false for 3