QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#61632#1807. Distribute the BarsyqyxWA 5ms6068kbC++17921b2022-11-14 11:49:162022-11-14 11:49:18

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:49:18]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:6068kb
  • [2022-11-14 11:49:16]
  • 提交

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();
	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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 6068kb

input:

4

output:

2
2 1 7 
2 3 5 

result:

ok OK (2 groups)

Test #2:

score: 0
Accepted
time: 0ms
memory: 5852kb

input:

2

output:

-1

result:

ok OK (impossible)

Test #3:

score: 0
Accepted
time: 4ms
memory: 5944kb

input:

3

output:

-1

result:

ok OK (impossible)

Test #4:

score: 0
Accepted
time: 5ms
memory: 5996kb

input:

1659

output:

3
553 1 9 17 19 3317 21 3315 23 3313 25 3311 27 3309 29 3307 31 3305 33 3303 35 3301 37 3299 39 3297 41 3295 43 3293 45 3291 47 3289 49 3287 51 3285 53 3283 55 3281 57 3279 59 3277 61 3275 63 3273 65 3271 67 3269 69 3267 71 3265 73 3263 75 3261 77 3259 79 3257 81 3255 83 3253 85 3251 87 3249 89 3247...

result:

ok OK (3 groups)

Test #5:

score: 0
Accepted
time: 2ms
memory: 5680kb

input:

8941

output:

-1

result:

ok OK (impossible)

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 5808kb

input:

458

output:

2
228 1 7 9 915 11 913 13 911 15 909 17 907 19 905 21 903 23 901 25 899 27 897 29 895 31 893 33 891 35 889 37 887 39 885 41 883 43 881 45 879 47 877 49 875 51 873 53 871 55 869 57 867 59 865 61 863 63 861 65 859 67 857 69 855 71 853 73 851 75 849 77 847 79 845 81 843 83 841 85 839 87 837 89 835 91 8...

result:

wrong answer Not all bars are distributed