QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#13526 | #1807. Distribute the Bars | JohnAlfnov | WA | 1ms | 6868kb | C++98 | 1010b | 2021-09-15 16:26:05 | 2022-05-17 02:41:32 |
Judging History
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