結果
問題 | No.2732 Similar Permutations |
ユーザー |
![]() |
提出日時 | 2024-04-05 00:43:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 106 ms / 2,000 ms |
コード長 | 1,114 bytes |
コンパイル時間 | 1,737 ms |
コンパイル使用メモリ | 136,928 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 00:43:02 |
合計ジャッジ時間 | 21,322 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 101 |
ソースコード
#include <iostream>#include <vector>#include <unordered_map>#include <algorithm>#include <ranges>int main() {int n; std::cin >> n;std::vector<int> a(n);for(auto& v : a) std::cin >> v;auto view = std::views::iota(1, n + 1);std::vector<int> ind(std::ranges::begin(view), std::ranges::end(view));std::unordered_map<int, int> mp;{int t = 0;do {int p = 0;for(int i : std::views::iota(0, n)) p ^= a[i] + ind[i];if(mp.contains(p)) {for(auto& v : ind) std::cout << v << " ";std::cout << "\n";ind.assign(std::ranges::begin(view), std::ranges::end(view));for([[maybe_unused]] const int _ : std::views::iota(0, mp[p])) {std::ranges::next_permutation(ind);}for(auto& v : ind) std::cout << v << " ";std::cout << "\n";return 0;}mp[p] = t++;} while(std::ranges::next_permutation(ind).found);}std::cout << -1 << "\n";}