結果

問題 No.2732 Similar Permutations
コンテスト
ユーザー umimel
提出日時 2024-04-24 21:58:28
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,278 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,274 ms
コンパイル使用メモリ 187,724 KB
実行使用メモリ 33,280 KB
最終ジャッジ日時 2026-05-07 15:51:39
合計ジャッジ時間 17,096 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 101
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:2:
In function '_OutIter std::__copy_move_a2(_InIter, _Sent, _OutIter) [with bool _IsMove = false; _InIter = int*; _Sent = int*; _OutIter = int*]',
    inlined from '_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = int*; _OI = int*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:492:42,
    inlined from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = int*; _OI = int*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:500:31,
    inlined from '_OI std::copy(_II, _II, _OI) [with _II = int*; _OI = int*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:642:7,
    inlined from 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/vector.tcc:255:17,
    inlined from 'void solve()' at main.cpp:39:18:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:426:32: warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' reading between 8589934592 and 9223372036854775804 bytes from a region of size 8589934588 [-Wstringop-overread]
  426 |               __builtin_memmove(_GLIBCXX_TO_ADDR(__result),
      |               ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  427 |                                 _GLIBCXX_TO_ADDR(__first),
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
  428 |                                 __n * sizeof(*__first));
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Ce

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const ll MOD1000000007 = 1000000007;
const ll MOD998244353 = 998244353;
const ll MOD[3] = {999727999, 1070777777, 1000000007};
const ll LINF = 1LL << 60LL;
const int IINF = (1 << 30) - 1;


void solve(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

    vector<vector<int>> ans(1<<20);
    vector<int> P(n);
    for(int i=0; i<n; i++) P[i] = i+1;

    do{
        int x = 0;
        for(int i=0; i<n; i++) x = x ^ (a[i] + P[i]);
        if((int)ans[x].size() > 0){
            for(int i=0; i<n; i++) cout << P[i] << ' ';
            cout << '\n';
            for(int i=0; i<n; i++) cout << ans[x][i] << ' ';
            cout << '\n';
            return;
        }
        ans[x] = P;
    }while(next_permutation(all(P)));

    cout << -1 << '\n';
    return;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int T=1;
    //cin >> T;
    while(T--) solve();
}
0