結果

問題 No.2732 Similar Permutations
ユーザー shobonvipshobonvip
提出日時 2024-04-19 23:10:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,572 ms / 2,000 ms
コード長 1,969 bytes
コンパイル時間 4,297 ms
コンパイル使用メモリ 258,640 KB
実行使用メモリ 461,824 KB
最終ジャッジ日時 2024-04-19 23:11:23
合計ジャッジ時間 44,695 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
15,696 KB
testcase_01 AC 6 ms
15,616 KB
testcase_02 AC 89 ms
31,052 KB
testcase_03 AC 408 ms
144,476 KB
testcase_04 AC 146 ms
53,320 KB
testcase_05 AC 89 ms
36,352 KB
testcase_06 AC 25 ms
19,952 KB
testcase_07 AC 447 ms
155,904 KB
testcase_08 AC 269 ms
69,248 KB
testcase_09 AC 64 ms
31,516 KB
testcase_10 AC 1,445 ms
458,752 KB
testcase_11 AC 17 ms
17,128 KB
testcase_12 AC 820 ms
221,824 KB
testcase_13 AC 353 ms
96,512 KB
testcase_14 AC 960 ms
341,180 KB
testcase_15 AC 397 ms
126,956 KB
testcase_16 AC 1,164 ms
412,640 KB
testcase_17 AC 478 ms
158,592 KB
testcase_18 AC 769 ms
238,080 KB
testcase_19 AC 967 ms
337,992 KB
testcase_20 AC 1,560 ms
461,824 KB
testcase_21 AC 821 ms
277,328 KB
testcase_22 AC 186 ms
64,364 KB
testcase_23 AC 786 ms
236,096 KB
testcase_24 AC 224 ms
62,336 KB
testcase_25 AC 213 ms
39,296 KB
testcase_26 AC 254 ms
69,336 KB
testcase_27 AC 158 ms
32,952 KB
testcase_28 AC 215 ms
62,192 KB
testcase_29 AC 200 ms
45,312 KB
testcase_30 AC 187 ms
59,136 KB
testcase_31 AC 285 ms
67,328 KB
testcase_32 AC 158 ms
36,572 KB
testcase_33 AC 229 ms
48,512 KB
testcase_34 AC 143 ms
32,128 KB
testcase_35 AC 204 ms
46,976 KB
testcase_36 AC 157 ms
35,328 KB
testcase_37 AC 119 ms
20,224 KB
testcase_38 AC 146 ms
19,540 KB
testcase_39 AC 132 ms
26,676 KB
testcase_40 AC 129 ms
18,916 KB
testcase_41 AC 100 ms
19,548 KB
testcase_42 AC 79 ms
18,492 KB
testcase_43 AC 105 ms
21,876 KB
testcase_44 AC 60 ms
20,096 KB
testcase_45 AC 121 ms
20,352 KB
testcase_46 AC 103 ms
18,432 KB
testcase_47 AC 115 ms
18,704 KB
testcase_48 AC 61 ms
17,596 KB
testcase_49 AC 102 ms
18,816 KB
testcase_50 AC 60 ms
17,024 KB
testcase_51 AC 103 ms
18,884 KB
testcase_52 AC 76 ms
18,176 KB
testcase_53 AC 640 ms
219,368 KB
testcase_54 AC 1,572 ms
449,792 KB
testcase_55 AC 1,036 ms
318,340 KB
testcase_56 AC 895 ms
304,880 KB
testcase_57 AC 290 ms
108,716 KB
testcase_58 AC 693 ms
220,160 KB
testcase_59 AC 391 ms
117,504 KB
testcase_60 AC 467 ms
149,376 KB
testcase_61 AC 464 ms
168,132 KB
testcase_62 AC 1,134 ms
346,240 KB
testcase_63 AC 9 ms
15,616 KB
testcase_64 AC 8 ms
15,488 KB
testcase_65 AC 6 ms
15,616 KB
testcase_66 AC 6 ms
15,488 KB
testcase_67 AC 7 ms
15,488 KB
testcase_68 AC 7 ms
15,616 KB
testcase_69 AC 7 ms
15,616 KB
testcase_70 AC 8 ms
15,616 KB
testcase_71 AC 7 ms
15,472 KB
testcase_72 AC 7 ms
15,488 KB
testcase_73 AC 6 ms
15,488 KB
testcase_74 AC 7 ms
15,472 KB
testcase_75 AC 7 ms
15,744 KB
testcase_76 AC 7 ms
15,612 KB
testcase_77 AC 6 ms
15,744 KB
testcase_78 AC 7 ms
15,488 KB
testcase_79 AC 6 ms
15,616 KB
testcase_80 AC 6 ms
15,744 KB
testcase_81 AC 7 ms
15,492 KB
testcase_82 AC 7 ms
15,492 KB
testcase_83 AC 7 ms
15,616 KB
testcase_84 AC 6 ms
15,616 KB
testcase_85 AC 6 ms
15,616 KB
testcase_86 AC 7 ms
15,488 KB
testcase_87 AC 14 ms
15,616 KB
testcase_88 AC 7 ms
15,488 KB
testcase_89 AC 6 ms
15,616 KB
testcase_90 AC 7 ms
15,744 KB
testcase_91 AC 7 ms
15,616 KB
testcase_92 AC 6 ms
15,616 KB
testcase_93 AC 7 ms
15,616 KB
testcase_94 AC 7 ms
15,616 KB
testcase_95 AC 7 ms
15,488 KB
testcase_96 AC 7 ms
15,488 KB
testcase_97 AC 7 ms
15,744 KB
testcase_98 AC 6 ms
15,568 KB
testcase_99 AC 6 ms
15,472 KB
testcase_100 AC 7 ms
15,488 KB
testcase_101 AC 7 ms
15,488 KB
testcase_102 AC 7 ms
15,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	random_device seed_gen;
	mt19937 engine(seed_gen());

	int n; cin >> n;
	vector<int> a(n);
	rep(i,0,n) cin >> a[i];

	if (n <= 10){
		vector<int> p(n);
		iota(p.begin(),p.end(),1);
		vector mem(1<<19,vector<int>(0));
		do{
			int r=0;
			rep(i,0,n)r^=a[i]+p[i];
			if(mem[r].size()>0){
				rep(i,0,n){
					cout << mem[r][i] << ' ';
				}
				cout << '\n';
				rep(i,0,n){
					cout << p[i] << ' ';
				}
				cout << '\n';
				return 0;
			}
			mem[r] = p;
		}while(next_permutation(p.begin(),p.end()));
		cout << -1 << '\n';
	}else{
		vector mem(1<<19,vector<int>(0));
		vector<int> p(n);
		iota(p.begin(), p.end(), 1);
		while(true){
			shuffle(p.begin(),p.end(),engine);
			int r=0;
			rep(i,0,n)r^=a[i]+p[i];
			if(mem[r].size()>0){
				rep(i,0,n){
					cout << mem[r][i] << ' ';
				}
				cout << '\n';
				rep(i,0,n){
					cout << p[i] << ' ';
				}
				cout << '\n';
				return 0;
			}
			mem[r] = p;
		}
	}
}

0