結果
| 問題 |
No.2732 Similar Permutations
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2024-04-19 22:22:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,026 bytes |
| コンパイル時間 | 2,600 ms |
| コンパイル使用メモリ | 205,976 KB |
| 最終ジャッジ日時 | 2025-02-21 04:34:35 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 91 WA * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
int main() {
fast_io();
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << -1 << endl;
return 0;
}
vector<int> p(n);
iota(p.begin(), p.end(), 1);
if (n <= 10) {
map<int, vector<int>> mp;
do {
int x = 0;
for (int i = 0; i < n; i++) {
x ^= a[i] + p[i];
}
if (mp.find(x) == mp.end()) {
mp[x] = p;
} else {
auto pp = mp[x];
for (int i = 0; i < n; i++) {
cout << pp[i] << " ";
}
cout << "\n";
for (int i = 0; i < n; i++) {
cout << p[i] << " ";
}
cout << "\n";
return 0;
}
} while (next_permutation(p.begin(), p.end()));
cout << -1 << endl;
return 0;
}
int s10 = 0;
for (int i = 10; i < n; i++) {
s10 ^= a[i] + (i + 1);
}
vector<int> p10(10);
iota(p10.begin(), p10.end(), 1);
map<int, vector<int>> mp;
do {
int x = s10;
for (int i = 0; i < 10; i++) {
x ^= a[i] + p10[i];
}
if (mp.find(x) == mp.end()) {
mp[x] = p;
} else {
auto pp = mp[x];
for (int i = 0; i < 10; i++) {
cout << pp[i] << " ";
}
for (int i = 11; i <= n; i++) {
cout << i << " ";
}
cout << "\n";
for (int i = 0; i < 10; i++) {
cout << p10[i] << " ";
}
for (int i = 11; i <= n; i++) {
cout << i << " ";
}
cout << "\n";
return 0;
}
} while (next_permutation(p10.begin(), p10.end()));
}
eve__fuyuki