結果
問題 | No.2732 Similar Permutations |
ユーザー | kureha |
提出日時 | 2024-04-19 23:01:02 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,924 bytes |
コンパイル時間 | 2,698 ms |
コンパイル使用メモリ | 210,524 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-10-11 17:07:27 |
合計ジャッジ時間 | 23,255 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 7 ms
7,884 KB |
testcase_02 | AC | 32 ms
11,392 KB |
testcase_03 | AC | 55 ms
14,336 KB |
testcase_04 | AC | 19 ms
9,984 KB |
testcase_05 | AC | 16 ms
9,472 KB |
testcase_06 | AC | 10 ms
8,448 KB |
testcase_07 | AC | 39 ms
12,928 KB |
testcase_08 | AC | 23 ms
10,368 KB |
testcase_09 | AC | 15 ms
9,088 KB |
testcase_10 | AC | 91 ms
19,200 KB |
testcase_11 | AC | 12 ms
8,704 KB |
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 | 6 ms
7,808 KB |
testcase_64 | AC | 7 ms
7,936 KB |
testcase_65 | AC | 6 ms
7,808 KB |
testcase_66 | AC | 6 ms
7,936 KB |
testcase_67 | AC | 6 ms
7,808 KB |
testcase_68 | AC | 6 ms
7,808 KB |
testcase_69 | AC | 7 ms
7,808 KB |
testcase_70 | AC | 6 ms
7,936 KB |
testcase_71 | AC | 6 ms
7,936 KB |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | AC | 6 ms
7,808 KB |
testcase_75 | AC | 6 ms
7,936 KB |
testcase_76 | AC | 6 ms
7,936 KB |
testcase_77 | AC | 6 ms
7,936 KB |
testcase_78 | AC | 6 ms
7,936 KB |
testcase_79 | AC | 6 ms
7,936 KB |
testcase_80 | AC | 6 ms
7,808 KB |
testcase_81 | AC | 6 ms
7,936 KB |
testcase_82 | AC | 7 ms
7,936 KB |
testcase_83 | AC | 6 ms
7,808 KB |
testcase_84 | AC | 6 ms
7,808 KB |
testcase_85 | AC | 6 ms
7,808 KB |
testcase_86 | AC | 6 ms
7,936 KB |
testcase_87 | AC | 7 ms
7,936 KB |
testcase_88 | AC | 6 ms
7,936 KB |
testcase_89 | WA | - |
testcase_90 | AC | 7 ms
7,936 KB |
testcase_91 | AC | 6 ms
7,808 KB |
testcase_92 | AC | 6 ms
7,936 KB |
testcase_93 | AC | 6 ms
7,808 KB |
testcase_94 | WA | - |
testcase_95 | AC | 6 ms
7,936 KB |
testcase_96 | AC | 6 ms
7,936 KB |
testcase_97 | AC | 6 ms
7,936 KB |
testcase_98 | AC | 6 ms
7,936 KB |
testcase_99 | AC | 6 ms
7,936 KB |
testcase_100 | AC | 6 ms
7,936 KB |
testcase_101 | AC | 6 ms
7,936 KB |
testcase_102 | AC | 6 ms
7,808 KB |
ソースコード
#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> 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; 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; 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(); }