QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#80518#5528. Least Annoying Constructive ProblemzhouhuanyiWA 2ms3500kbC++141.2kb2023-02-24 09:26:252023-02-24 09:26:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-24 09:26:26]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3500kb
  • [2023-02-24 09:26:25]
  • 提交

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