結果
問題 | No.2732 Similar Permutations |
ユーザー | GOTKAKO |
提出日時 | 2024-04-19 22:34:33 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,906 bytes |
コンパイル時間 | 2,607 ms |
コンパイル使用メモリ | 220,356 KB |
実行使用メモリ | 15,104 KB |
最終ジャッジ日時 | 2024-10-11 16:12:29 |
合計ジャッジ時間 | 27,375 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 129 ms
14,848 KB |
testcase_14 | AC | 128 ms
14,848 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 126 ms
14,720 KB |
testcase_21 | AC | 129 ms
14,976 KB |
testcase_22 | AC | 71 ms
9,728 KB |
testcase_23 | AC | 131 ms
14,848 KB |
testcase_24 | AC | 73 ms
9,984 KB |
testcase_25 | AC | 129 ms
14,848 KB |
testcase_26 | AC | 106 ms
12,800 KB |
testcase_27 | AC | 132 ms
14,848 KB |
testcase_28 | AC | 100 ms
12,288 KB |
testcase_29 | AC | 130 ms
14,976 KB |
testcase_30 | AC | 91 ms
11,392 KB |
testcase_31 | AC | 133 ms
14,848 KB |
testcase_32 | AC | 122 ms
13,952 KB |
testcase_33 | AC | 131 ms
14,848 KB |
testcase_34 | AC | 85 ms
10,752 KB |
testcase_35 | AC | 132 ms
14,848 KB |
testcase_36 | AC | 120 ms
13,952 KB |
testcase_37 | AC | 132 ms
14,848 KB |
testcase_38 | AC | 114 ms
13,312 KB |
testcase_39 | AC | 131 ms
14,848 KB |
testcase_40 | AC | 109 ms
12,800 KB |
testcase_41 | AC | 132 ms
14,848 KB |
testcase_42 | AC | 96 ms
11,776 KB |
testcase_43 | AC | 132 ms
14,848 KB |
testcase_44 | AC | 66 ms
9,344 KB |
testcase_45 | AC | 131 ms
14,976 KB |
testcase_46 | AC | 117 ms
13,696 KB |
testcase_47 | AC | 128 ms
14,848 KB |
testcase_48 | AC | 77 ms
10,240 KB |
testcase_49 | AC | 128 ms
14,848 KB |
testcase_50 | AC | 75 ms
10,112 KB |
testcase_51 | AC | 124 ms
14,848 KB |
testcase_52 | AC | 104 ms
13,056 KB |
testcase_53 | WA | - |
testcase_54 | AC | 127 ms
14,848 KB |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | AC | 64 ms
9,216 KB |
testcase_58 | AC | 90 ms
11,264 KB |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | AC | 2 ms
5,248 KB |
testcase_64 | AC | 2 ms
5,248 KB |
testcase_65 | AC | 2 ms
5,248 KB |
testcase_66 | AC | 2 ms
5,248 KB |
testcase_67 | AC | 3 ms
5,248 KB |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
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 | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; if(N == 1){cout << -1 << endl; return 0;} vector<pair<int,int>> A(N); for(int i=0; i<N; i++) cin >> A.at(i).first,A.at(i).second = i; sort(A.begin(),A.end()); set<int> idx; for(int i=1; i<=N; i++) idx.insert(i); int swap1 = -1,swap2 = -1; vector<int> answer(N); for(int i=0; i<N-1; i++){ auto[a1,pos1] = A.at(i); auto[a2,pos2] = A.at(i+1); if(a1 == a2){ swap1 = pos1,swap2 = pos2; answer.at(pos1) = 1,answer.at(pos2) = 2; idx.erase(1); idx.erase(2); break; } vector<int> same,diff; for(int k=0; k<20; k++){ if((a1&(1<<k)) != (a2&(1<<k))) diff.push_back(1<<k); else same.push_back(1<<k); } sort(same.begin(),same.end()); sort(diff.begin(),diff.end()); int mind = diff.at(0)+same.at(0); if(diff.size() > 1) mind = min(mind,diff.at(1)); if(mind > N) continue; swap1 = pos1,swap2 = pos2; if(diff.size() > 1) if(mind == diff.at(1)){ answer.at(pos1) = mind,answer.at(pos2) = diff.at(0); idx.erase(mind),idx.erase(diff.at(0)); break; } answer.at(pos1) = mind,answer.at(pos2) = mind-diff.at(0); idx.erase(mind); idx.erase(mind-diff.at(0)); break; } if(swap1 == -1){cout << -1 << endl; return 0;} for(auto &a : answer) if(a == 0) a = *idx.begin(),idx.erase(idx.begin()); for(int i=0; i<N; i++) cout << answer.at(i) << (i==N-1?"\n":" "); for(int i=0; i<N; i++){ if(i != swap1 && i != swap2) cout << answer.at(i) << (i==N-1?"\n":" "); if(i == swap1) cout << answer.at(swap2) << (i==N-1?"\n":" "); if(i == swap2) cout << answer.at(swap1) << (i==N-1?"\n":" "); } }