QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#13526#1807. Distribute the BarsJohnAlfnovWA 1ms6868kbC++981010b2021-09-15 16:26:052022-05-17 02:41:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-17 02:41:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6868kb
  • [2021-09-15 16:26:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct apple
{
	long long he;
	vector<int>g;
	bool operator<(const apple &other)const
	{
		return he<other.he;
	}
}e[100005];
int cmp(int a,int b)
{
	return e[a].he<e[b].he;
}
int main()
{
	int n,flag=0;
	cin>>n;
	for(int i=n-1;i>=2;i--)if(n%i==0)flag=i;
	if(!flag)cout<<-1<<endl;
	else
	{
		if(n%2==0)
		{
			printf("%d\n",n/2);
			for(int i=1;i<=n/2;i++)printf("%d %d %d\n",2,i,n-i+1);
		}else
		{
			int x=flag,y=n/flag;
			cout<<y<<endl;
			for(int i=1;i<=y;i++)
			{
				e[i].g.push_back(2*i-1);
				int D=y+(i+y/2)%y+1;
				e[i].g.push_back(2*D-1);
				e[i].he=2*i-1+2*D-1;
			}
			sort(e+1,e+y+1);
			for(int i=1;i<=y;i++)
			{
				printf("%d",x);
				for(int j=0;j<2;j++)printf(" %d",e[i].g[j]);
				int D=3*y-i+1;
				printf(" %d",2*D-1);
				for(int j=4;j<=x;j+=2)
				{
					int D1=(j-1)*y+i+1,D2=(j-1)*y+(y-i)+1;
					printf(" %d %d",2*D1-1,2*D2-1);
				}
				printf("\n");
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6868kb

input:

4

output:

2
2 1 4
2 2 3

result:

wrong answer Even numbers not allowed