結果

問題 No.2732 Similar Permutations
ユーザー butsurizukibutsurizuki
提出日時 2024-04-19 21:44:53
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 956 bytes
コンパイル時間 4,762 ms
コンパイル使用メモリ 280,856 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2024-04-19 21:45:14
合計ジャッジ時間 17,528 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
15,380 KB
testcase_01 AC 8 ms
15,360 KB
testcase_02 AC 22 ms
15,872 KB
testcase_03 AC 34 ms
15,984 KB
testcase_04 AC 16 ms
15,640 KB
testcase_05 AC 14 ms
15,604 KB
testcase_06 AC 12 ms
15,616 KB
testcase_07 AC 27 ms
15,872 KB
testcase_08 AC 17 ms
15,744 KB
testcase_09 AC 13 ms
15,456 KB
testcase_10 AC 52 ms
16,256 KB
testcase_11 AC 12 ms
15,508 KB
testcase_12 AC 59 ms
16,384 KB
testcase_13 AC 55 ms
16,128 KB
testcase_14 AC 54 ms
16,256 KB
testcase_15 AC 53 ms
16,128 KB
testcase_16 AC 43 ms
15,936 KB
testcase_17 AC 41 ms
16,028 KB
testcase_18 AC 50 ms
16,128 KB
testcase_19 AC 56 ms
16,256 KB
testcase_20 AC 55 ms
16,264 KB
testcase_21 AC 55 ms
16,384 KB
testcase_22 AC 34 ms
15,872 KB
testcase_23 AC 56 ms
16,384 KB
testcase_24 AC 36 ms
16,000 KB
testcase_25 AC 54 ms
16,256 KB
testcase_26 AC 47 ms
16,256 KB
testcase_27 AC 53 ms
16,384 KB
testcase_28 AC 46 ms
16,000 KB
testcase_29 AC 53 ms
16,256 KB
testcase_30 AC 41 ms
16,204 KB
testcase_31 AC 53 ms
16,248 KB
testcase_32 AC 64 ms
16,256 KB
testcase_33 AC 54 ms
16,252 KB
testcase_34 AC 38 ms
16,000 KB
testcase_35 AC 55 ms
16,288 KB
testcase_36 AC 51 ms
16,128 KB
testcase_37 AC 54 ms
16,256 KB
testcase_38 AC 48 ms
16,376 KB
testcase_39 AC 53 ms
16,256 KB
testcase_40 AC 45 ms
16,128 KB
testcase_41 AC 53 ms
16,188 KB
testcase_42 AC 43 ms
16,000 KB
testcase_43 AC 54 ms
16,184 KB
testcase_44 AC 32 ms
15,796 KB
testcase_45 AC 53 ms
16,256 KB
testcase_46 AC 49 ms
16,320 KB
testcase_47 AC 52 ms
16,248 KB
testcase_48 AC 35 ms
15,872 KB
testcase_49 AC 52 ms
16,256 KB
testcase_50 AC 36 ms
16,128 KB
testcase_51 AC 50 ms
16,176 KB
testcase_52 AC 43 ms
16,080 KB
testcase_53 AC 53 ms
16,256 KB
testcase_54 AC 55 ms
16,384 KB
testcase_55 AC 53 ms
16,128 KB
testcase_56 AC 54 ms
16,316 KB
testcase_57 AC 32 ms
15,948 KB
testcase_58 AC 42 ms
16,180 KB
testcase_59 AC 39 ms
16,000 KB
testcase_60 AC 34 ms
15,928 KB
testcase_61 AC 31 ms
15,796 KB
testcase_62 AC 47 ms
16,036 KB
testcase_63 AC 7 ms
15,488 KB
testcase_64 AC 7 ms
15,488 KB
testcase_65 AC 7 ms
15,360 KB
testcase_66 AC 7 ms
15,360 KB
testcase_67 AC 7 ms
15,488 KB
testcase_68 AC 7 ms
15,608 KB
testcase_69 AC 7 ms
15,580 KB
testcase_70 AC 7 ms
15,448 KB
testcase_71 AC 7 ms
15,360 KB
testcase_72 AC 8 ms
15,496 KB
testcase_73 AC 7 ms
15,488 KB
testcase_74 AC 7 ms
15,488 KB
testcase_75 AC 7 ms
15,488 KB
testcase_76 AC 7 ms
15,488 KB
testcase_77 AC 7 ms
15,488 KB
testcase_78 AC 7 ms
15,600 KB
testcase_79 AC 7 ms
15,360 KB
testcase_80 AC 7 ms
15,488 KB
testcase_81 AC 7 ms
15,488 KB
testcase_82 AC 7 ms
15,488 KB
testcase_83 AC 8 ms
15,616 KB
testcase_84 AC 7 ms
15,360 KB
testcase_85 AC 7 ms
15,548 KB
testcase_86 AC 7 ms
15,488 KB
testcase_87 AC 7 ms
15,488 KB
testcase_88 AC 7 ms
15,552 KB
testcase_89 AC 7 ms
15,488 KB
testcase_90 AC 7 ms
15,556 KB
testcase_91 AC 7 ms
15,580 KB
testcase_92 AC 7 ms
15,616 KB
testcase_93 AC 7 ms
15,488 KB
testcase_94 AC 7 ms
15,380 KB
testcase_95 AC 7 ms
15,488 KB
testcase_96 AC 7 ms
15,488 KB
testcase_97 AC 8 ms
15,492 KB
testcase_98 AC 7 ms
15,360 KB
testcase_99 AC 7 ms
15,488 KB
testcase_100 AC 7 ms
15,488 KB
testcase_101 AC 7 ms
15,488 KB
testcase_102 AC 7 ms
15,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &nx : a){cin >> nx;}

  int sn=min(n,10);
  vector<int> p;
  for(int i=1;i<=sn;i++){
    p.push_back(i);
  }
  vector<vector<int>> mem(1<<19);
  vector<int> r1,r2;
  do{
    int cf=0;
    for(int i=0;i<sn;i++){
      cf^=(a[i]+p[i]);
    }
    // cerr << cf << "\n";
    if(mem[cf].empty()){
      mem[cf]=p;
    }
    else{
      r1=mem[cf];
      r2=p;
      break;
    }
  }while(next_permutation(p.begin(),p.end()));

  if(r1.empty()){cout << "-1\n";return 0;}

  for(int i=0;i<sn;i++){
    if(i){cout << " ";}
    cout << r1[i];
  }
  for(int i=sn+1;i<=n;i++){
    if(i){cout << " ";}
    cout << i;
  }cout << "\n";

  for(int i=0;i<sn;i++){
    if(i){cout << " ";}
    cout << r2[i];
  }
  for(int i=sn+1;i<=n;i++){
    if(i){cout << " ";}
    cout << i;
  }cout << "\n";
  return 0;
}
0