結果
| 問題 |
No.2732 Similar Permutations
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-04-25 16:40:24 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,486 bytes |
| コンパイル時間 | 7,221 ms |
| コンパイル使用メモリ | 262,640 KB |
| 最終ジャッジ日時 | 2025-02-21 08:59:26 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 WA * 2 RE * 58 TLE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
//500000<=2^19-1=524287
//総XORは524287以下
//最初の10項を並び替えるだけで3628800通りの値が作れる
int N, S;
cin >> N;
vector<int> A(N);
for (int i=0; i<N; i++) cin >> A[i];
vector<int> p(min(N, 10));
iota(p.begin(), p.end(), 1);
vector<vector<int>> v(550000);
if (N<=9){
do{
S = 0;
for (int i=0; i<N; i++){
S ^= p[i]+A[i];
}
if (v[S].size() == 0) v[S] = p;
else{
for (auto x : p) cout << x << " ";
cout << endl;
for (auto x : v[S]) cout << x << " ";
cout << endl;
return 0;
}
} while(next_permutation(p.begin(), p.end()));
cout << -1 << endl;
return 0;
}
do{
S = 0;
for (int i=0; i<N; i++){
S ^= p[i]+A[i];
}
if (v[S].size() == 0) v[S] = p;
else{
for (auto x : p) cout << x << " ";
for (int i=11; i<=N; i++) cout << i << " ";
cout << endl;
for (auto x : v[S]) cout << x << " ";
for (int i=11; i<=N; i++) cout << i << " ";
cout << endl;
return 0;
}
} while(next_permutation(p.begin(), p.end()));
return 0;
}
srjywrdnprkt