結果

問題 No.2732 Similar Permutations
ユーザー 👑 kmjpkmjp
提出日時 2024-04-19 23:32:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 1,601 bytes
コンパイル時間 2,395 ms
コンパイル使用メモリ 198,616 KB
実行使用メモリ 6,732 KB
最終ジャッジ日時 2024-04-19 23:32:29
合計ジャッジ時間 15,849 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 15 ms
5,376 KB
testcase_03 AC 26 ms
5,376 KB
testcase_04 AC 10 ms
5,376 KB
testcase_05 AC 7 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 21 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 46 ms
6,392 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 50 ms
6,512 KB
testcase_13 AC 50 ms
6,512 KB
testcase_14 AC 49 ms
6,508 KB
testcase_15 AC 49 ms
6,376 KB
testcase_16 AC 35 ms
5,612 KB
testcase_17 AC 34 ms
5,740 KB
testcase_18 AC 45 ms
6,252 KB
testcase_19 AC 47 ms
6,380 KB
testcase_20 AC 48 ms
6,512 KB
testcase_21 AC 49 ms
6,512 KB
testcase_22 AC 28 ms
5,376 KB
testcase_23 AC 47 ms
6,380 KB
testcase_24 AC 29 ms
5,376 KB
testcase_25 AC 50 ms
6,504 KB
testcase_26 AC 41 ms
5,996 KB
testcase_27 AC 49 ms
6,504 KB
testcase_28 AC 37 ms
5,744 KB
testcase_29 AC 48 ms
6,508 KB
testcase_30 AC 34 ms
5,612 KB
testcase_31 AC 48 ms
6,380 KB
testcase_32 AC 44 ms
6,252 KB
testcase_33 AC 47 ms
6,380 KB
testcase_34 AC 49 ms
5,376 KB
testcase_35 AC 48 ms
6,508 KB
testcase_36 AC 48 ms
6,384 KB
testcase_37 AC 50 ms
6,384 KB
testcase_38 AC 42 ms
6,124 KB
testcase_39 AC 49 ms
6,376 KB
testcase_40 AC 41 ms
5,868 KB
testcase_41 AC 47 ms
6,508 KB
testcase_42 AC 36 ms
5,868 KB
testcase_43 AC 47 ms
6,636 KB
testcase_44 AC 25 ms
5,376 KB
testcase_45 AC 47 ms
6,380 KB
testcase_46 AC 44 ms
6,124 KB
testcase_47 AC 48 ms
6,508 KB
testcase_48 AC 29 ms
5,376 KB
testcase_49 AC 46 ms
6,512 KB
testcase_50 AC 28 ms
5,376 KB
testcase_51 AC 44 ms
6,632 KB
testcase_52 AC 38 ms
5,996 KB
testcase_53 AC 49 ms
6,644 KB
testcase_54 AC 46 ms
6,732 KB
testcase_55 AC 47 ms
6,604 KB
testcase_56 AC 48 ms
6,580 KB
testcase_57 AC 27 ms
5,376 KB
testcase_58 AC 35 ms
5,688 KB
testcase_59 AC 33 ms
5,376 KB
testcase_60 AC 26 ms
5,376 KB
testcase_61 AC 25 ms
5,376 KB
testcase_62 AC 40 ms
5,964 KB
testcase_63 AC 1 ms
5,376 KB
testcase_64 AC 2 ms
5,376 KB
testcase_65 AC 2 ms
5,376 KB
testcase_66 AC 1 ms
5,376 KB
testcase_67 AC 2 ms
5,376 KB
testcase_68 AC 1 ms
5,376 KB
testcase_69 AC 1 ms
5,376 KB
testcase_70 AC 2 ms
5,376 KB
testcase_71 AC 1 ms
5,376 KB
testcase_72 AC 2 ms
5,376 KB
testcase_73 AC 2 ms
5,376 KB
testcase_74 AC 1 ms
5,376 KB
testcase_75 AC 1 ms
5,376 KB
testcase_76 AC 1 ms
5,376 KB
testcase_77 AC 1 ms
5,376 KB
testcase_78 AC 1 ms
5,376 KB
testcase_79 AC 2 ms
5,376 KB
testcase_80 AC 2 ms
5,376 KB
testcase_81 AC 2 ms
5,376 KB
testcase_82 AC 1 ms
5,376 KB
testcase_83 AC 2 ms
5,376 KB
testcase_84 AC 2 ms
5,376 KB
testcase_85 AC 2 ms
5,376 KB
testcase_86 AC 1 ms
5,376 KB
testcase_87 AC 1 ms
5,376 KB
testcase_88 AC 2 ms
5,376 KB
testcase_89 AC 2 ms
5,376 KB
testcase_90 AC 2 ms
5,376 KB
testcase_91 AC 1 ms
5,376 KB
testcase_92 AC 1 ms
5,376 KB
testcase_93 AC 1 ms
5,376 KB
testcase_94 AC 1 ms
5,376 KB
testcase_95 AC 2 ms
5,376 KB
testcase_96 AC 1 ms
5,376 KB
testcase_97 AC 2 ms
5,376 KB
testcase_98 AC 2 ms
5,376 KB
testcase_99 AC 1 ms
5,376 KB
testcase_100 AC 2 ms
5,376 KB
testcase_101 AC 1 ms
5,376 KB
testcase_102 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
int A[202020];
int P[2][202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	vector<int> C[2];
	FOR(i,N) {
		cin>>A[i];
		C[A[i]%2].push_back(i);
	}
	if(N==1) {
		cout<<-1<<endl;
	}
	else if(N==2) {
		if(((A[0]+1)^(A[1]+2))==((A[0]+2)^(A[1]+1))) {
			cout<<1<<" "<<2<<endl;
			cout<<2<<" "<<1<<endl;
		}
		else {
			cout<<-1<<endl;
		}
	}
	else {
		if(C[1].size()>=2) {
			x=C[1][0];
			y=C[1][1];
			k=3;
			P[0][x]=P[1][y]=1;
			P[0][y]=P[1][x]=2;
			
			FOR(i,N) if(i!=x&&i!=y) P[0][i]=P[1][i]=k++;
		}
		else {
			x=C[0][0];
			y=C[0][1];
			k=1;
			P[0][x]=P[1][y]=2;
			P[0][y]=P[1][x]=3;
			
			FOR(i,N) if(i!=x&&i!=y) {
				P[0][i]=P[1][i]=k++;
				if(k==2) k=4;
			}
		}
		FOR(i,N) cout<<P[0][i]<<" ";
		cout<<endl;
		FOR(i,N) cout<<P[1][i]<<" ";
		cout<<endl;
		
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0