QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#61636#1807. Distribute the BarsyqyxWA 5ms5908kbC++171.0kb2022-11-14 11:56:092022-11-14 11:57:02

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-14 11:57:02]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:5908kb
  • [2022-11-14 11:56:09]
  • 提交

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