結果

問題 No.2732 Similar Permutations
ユーザー kurehakureha
提出日時 2024-04-19 23:10:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,639 bytes
コンパイル時間 2,459 ms
コンパイル使用メモリ 206,348 KB
実行使用メモリ 40,448 KB
最終ジャッジ日時 2024-04-19 23:10:53
合計ジャッジ時間 23,512 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
31,252 KB
testcase_02 AC 43 ms
34,304 KB
testcase_03 WA -
testcase_04 AC 27 ms
32,988 KB
testcase_05 AC 31 ms
32,512 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 13 ms
31,232 KB
testcase_64 AC 13 ms
31,232 KB
testcase_65 AC 13 ms
31,476 KB
testcase_66 AC 13 ms
31,428 KB
testcase_67 AC 12 ms
31,476 KB
testcase_68 AC 12 ms
31,484 KB
testcase_69 AC 13 ms
31,360 KB
testcase_70 AC 13 ms
31,480 KB
testcase_71 AC 13 ms
31,320 KB
testcase_72 AC 13 ms
31,312 KB
testcase_73 AC 12 ms
31,324 KB
testcase_74 AC 13 ms
31,232 KB
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 AC 13 ms
31,232 KB
testcase_79 AC 12 ms
31,232 KB
testcase_80 WA -
testcase_81 AC 13 ms
31,232 KB
testcase_82 WA -
testcase_83 AC 13 ms
31,360 KB
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 WA -
testcase_99 WA -
testcase_100 WA -
testcase_101 WA -
testcase_102 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T> using VVVV = VV<VV<T>>;
#define rep(i,n) for(ll i=0ll;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)
const long long INF = (1LL << 60);
const long long mod99 = 998244353;
const long long mod107 = 1000000007;
const long long mod = mod99;
#define eb emplace_back
#define pb eb
#define be(v) (v).begin(),(v).end()
#define all(i,v) for(auto& i : v)
#define all2(i,j,v) for(auto& [i,j] : v)
template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

// cin.tie(nullptr);
// ios::sync_with_stdio(false);
// cout << fixed << setprecision(20);

ll Rnd(ll L=0, ll R=mod99){
  return rand()%(R-L)+L;
}

void solve(){
  ll n;
  cin >> n;
  V<ll> v(n);
  rep(i,n) cin >> v[i];
  VV<ll> pos(200100);
  rep(i, n) pos[v[i]].eb(i);
  
  rep(i, 200100) if(pos[i].size()>=2){
    V<ll> ans(n);
    cout << "Yes" << endl;
    rep(i, n){
      cout << i+1 << " ";
      ans[i] = i+1;
    }
    cout << endl;
    swap(ans[pos[i][0]],ans[pos[i][1]]);
    all(i,ans) cout << i << " ";
    cout << endl;
    return;
  }
  {
  VV<ll> w(1001000);
  rep(i, n){
    V<ll> vv;
    rep(j, 20) if(((v[i]>>j)&1)==0) vv.eb(j);
    if((1<<vv[0])*2+1>n) continue;
    ll x = (1<<vv[0])+(1<<vv[1]);
    w[x].eb(i);
    if(w[x].size()<2) continue;
    ll a = w[x][0], b = w[x][1];
    ll A = 1, B = (1<<v[0])*2+1;
    V<ll> ans(n, -1);
    ans[a] = A;
    ans[b] = B;
    ll cnt = 1;
    while(cnt==A||cnt==B) cnt++;
    rep(i, n) if(ans[i]==-1){
      ans[i] = cnt;
      cnt++;
      while(cnt==A||cnt==B) cnt++;
    }
    rep(i, n) cout << ans[i] << " ";
    cout << endl;
    swap(ans[a],ans[b]);
    rep(i, n) cout << ans[i] << " ";
    cout << endl;
    return;
  }
  }
  {VV<ll> vv(32);
  rep(i, n) vv[v[i]%32].eb(i);
  rep(i, 32) rep(j, 32){
    if(i==j) if(vv[i].size()>=2){
      V<ll> ans(n, -1);
      ll x = vv[i][0], y = vv[i][1];
      ll a = -1, b = -1;
      REP(i,1, min(n+1, 65ll)) REP(j,1,i){
        ll aa = (v[x]+i)^(v[y]+j); 
        ll bb = (v[y]+i)^(v[x]+j);
        if(aa!=bb) continue;
        a = i;
        b = j;
      }
      if(a == -1) continue;
      ans[x] = a;
      ans[y] = b;
      ll cnt = 1;
      while(cnt==a||cnt==b) cnt++;
      rep(i, n) if(ans[i] == -1){
        ans[i] = cnt;
        cnt++;
        while(a==cnt||b==cnt) cnt++;
      }
      rep(i, n) cout << ans[i] << " ";
      cout << endl;
      swap(ans[x], ans[y]);
      rep(i, n) cout << ans[i] << " ";
      cout << endl;
      return;
    }
    if(i!=j) if(vv[i].size()>=1 && vv[j].size()>=1){
      V<ll> ans(n, -1);
      ll x = vv[i][0], y = vv[j][0];
      ll a = -1, b = -1;
      REP(i,1, min(n+1, 65ll)) REP(j,1,i){
        ll aa = (v[x]+i)^(v[y]+j); 
        ll bb = (v[y]+i)^(v[x]+j);
        if(aa!=bb) continue;
        a = i;
        b = j;
      }
      if(a == -1) continue;
      ans[x] = a;
      ans[y] = b;
      ll cnt = 1;
      while(cnt==a||cnt==b) cnt++;
      rep(i, n) if(ans[i] == -1){
        ans[i] = cnt;
        cnt++;
        while(a==cnt||b==cnt) cnt++;
      }
      rep(i, n) cout << ans[i] << " ";
      cout << endl;
      swap(ans[x], ans[y]);
      rep(i, n) cout << ans[i] << " ";
      cout << endl;
      return;
    }
  }
  }
  cout << -1 << endl;
}





int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int t=1;
  // cin >> t;
  rep(i,t) solve();
}
0