#line 1 "main.cpp" #ifdef LOCAL #include #else #include #define debug(...) ((void)0) #define postprocess(...) ((void)0) #endif #line 2 "library/misc/xorshift.hpp" #include inline uint32_t xorshift32() { static uint32_t x = std::chrono::high_resolution_clock::now().time_since_epoch().count(); x ^= x << 13; x ^= x >> 17; x ^= x << 5; return x; } inline uint64_t xorshift64() { static uint64_t x = std::chrono::high_resolution_clock::now().time_since_epoch().count(); x ^= x << 13; x ^= x >> 7; x ^= x << 17; return x; } #line 10 "main.cpp" using namespace std; using ll = long long; using ld = long double; struct RNG { void setSeed(uint64_t seed) { seedSet = true; x = seed; } template T choice(std::vector& v) { assert(!v.empty()); return v[range(0, (int)v.size() - 1)]; } template void shuffle(std::vector& v) { const int N = v.size(); for (int i = 0; i < N - 1; i++) { const int j = range(i, N - 1); if (i == j) continue; std::swap(v[i], v[j]); } } // generate random integers in [from, to] template typename std::common_type::type range(T from, U to) { static_assert(std::is_integral_v); static_assert(std::is_integral_v); static_assert(std::is_integral_v::type>); assert(from <= to); uint64_t width = to - from + 1; typename std::common_type::type ret = from; ret += xorshift64() % width; return ret; } private: bool seedSet = false; uint64_t x; uint64_t xorshift64() { assert(seedSet); x ^= x << 13; x ^= x >> 7; x ^= x << 17; return x; } } rng; vector random_permutation(const int N, const uint64_t seed) { rng.setSeed(seed); vector ret(N); iota(ret.begin(), ret.end(), 1); rng.shuffle(ret); return ret; } uint64_t memo[1000000]; void solve([[maybe_unused]] int test) { int N; cin >> N; vector A(N); for (auto&& x : A) { cin >> x; } auto start = chrono::high_resolution_clock::now(); while (true) { auto now = chrono::high_resolution_clock::now(); auto ms = chrono::duration_cast(now - start).count(); if (ms > 1950) break; const uint64_t seed = max(1ul, xorshift64()); const auto P = random_permutation(N, seed); int xorsum = 0; for (int i = 0; i < N; i++) { xorsum ^= (P[i] + A[i]); } if (memo[xorsum] > 0) { const auto P2 = random_permutation(N, memo[xorsum]); if (P != P2) { for (int i = 0; i < N; i++) { cout << P[i] << (i == N - 1 ? "\n" : " "); } for (int i = 0; i < N; i++) { cout << P2[i] << (i == N - 1 ? "\n" : " "); } return; } } memo[xorsum] = seed; } cout << -1 << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { solve(i); } postprocess(); }