QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61636 | #1807. Distribute the Bars | yqyx | WA | 5ms | 5908kb | C++17 | 1.0kb | 2022-11-14 11:56:09 | 2022-11-14 11:57:02 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define N 100012
#define mkp make_pair
#define pb push_back
using namespace std;
ll read(){
ll x=0,fl=1; char ch=getchar();
while(ch<'0'||ch>'9'){ if(ch=='-')fl=-1; ch=getchar();}
while(ch>='0'&&ch<='9'){ x=x*10+ch-'0'; ch=getchar();}
return x*fl;
}
int n;
vector<int> a[N];
int main(){
n=read();
if(n%2==0){
printf("%d\n",n/2);
int l=1,r=n;
for(int i=1;i<=n/2;i++,l++,r--){
printf("2 %d %d\n",l*2-1,r*2-1);
}
return 0;
}
int jl=0;
for(int i=2;i*i<=n;i++){
if(n%i==0){ jl=i; break;}
}
if(!jl){
printf("-1"); return 0;
}
for(int i=1;i<=jl;i++){
int k=i;
for(int j=1;j<=jl;j++){
if(k>jl) k=1;
a[i].pb(jl*(j-1)+k);
k++;
}
}
int p=(n-jl*jl)/jl/2;
int l=jl*jl+1,r=n;
for(int i=1;i<=jl;i++){
for(int j=1;j<=p;j++){
a[i].pb(l); a[i].pb(r);
l++,r--;
}
}
printf("%d\n",jl);
for(int i=1;i<=jl;i++){
printf("%d ",(int)a[i].size());
for(int j:a[i]){
printf("%d ",j*2-1);
}
printf("\n");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5908kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 5836kb
input:
2
output:
1 2 1 3
result:
wrong answer M=1 is too small