結果

問題 No.1061 素敵な数列
ユーザー furafura
提出日時 2020-05-23 02:16:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,398 bytes
コンパイル時間 2,976 ms
コンパイル使用メモリ 198,604 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-04-15 23:25:31
合計ジャッジ時間 13,836 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 RE -
testcase_04 AC 2 ms
5,376 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
5,376 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 2 ms
5,376 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

vector<int> solve2(int n);

vector<int> solve1(int n){
	if(n==1) return {0,0,0};
	if(n==5) return {0,0,0,4,1,1,4,1,2,3,3,2,2,4,3};

	vector<int> res(3*n);
	if(n%2==1){
		int idx=0;
		for(int a:solve1(n/2)){
			res[idx++]=a;
		}
		for(int i=n-1;i>=n/2;i--){
			res[idx++]=i;
			res[idx++]=i;
		}
		for(int i=n-1;i>=n/2;i--){
			res[idx++]=i;
		}
	}
	else{
		int idx=0;
		for(int i=n/2;i<n;i++){
			res[idx++]=i;
		}
		res[idx++]=n-1;
		for(int i=n/2;i<n;i++){
			res[idx++]=i;
			res[idx++]=i;
		}
		int idx2=idx+1;
		for(int a:solve1(n/2)){
			res[idx++]=a;
		}
		res[idx2]=n-1;
	}
	return res;
}

vector<int> solve2(int n){
	if(n==3) return {1,-1,1,2,0,1,0,2,0,2};
	if(n==4) return {1,-1,1,3,3,1,0,2,3,0,2,2,0};

	vector<int> res(3*n+1);
	if(n%2==1){
		int idx=0;
		for(int a:solve2(n/2)){
			res[idx++]=a;
		}
		for(int i=n-1;i>=n/2;i--){
			res[idx++]=i;
			res[idx++]=i;
		}
		for(int i=n-1;i>=n/2;i--){
			res[idx++]=i;
		}
	}
	else{
		int idx=0;
		for(int i=n-1;i>=n/2;i--){
			res[idx++]=i;
			res[idx++]=i;
		}
		res[idx++]=n-1;
		for(int i=n-1;i>=n/2;i--){
			res[idx++]=i;
		}
		for(int a:solve1(n/2)){
			res[idx++]=a;
		}
	}
	return res;
}

int main(){
	int n; scanf("%d",&n);

	if(n==2) return puts("-1"),0;

	auto ans=solve1(n);
	rep(i,3*n) printf("%d%c",ans[i],i<3*n-1?' ':'\n');

	return 0;
}
0