結果
問題 | No.2061 XOR Sort |
ユーザー |
![]() |
提出日時 | 2025-03-29 08:36:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,018 bytes |
コンパイル時間 | 3,471 ms |
コンパイル使用メモリ | 282,260 KB |
実行使用メモリ | 21,532 KB |
最終ジャッジ日時 | 2025-03-29 08:37:17 |
合計ジャッジ時間 | 25,902 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 TLE * 6 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/modint>using namespace std;using namespace atcoder;using ll = long long;using mint = modint998244353;int main(){cin.tie(nullptr);ios_base::sync_with_stdio(false);/*最終的にAの多重集合とBの多重集合は同じ。よって、xorを作用させた時点でどのように大小が入れ替わるかが重要。Binary Trieを思い出すと、xorを作用させるということは二分木の左右のノードを入れ替えること。二分木がある階層の数をxとすると2^xが答え。*/ll N, x=0;cin >> N;vector<ll> A(N);for (int i=0; i<N; i++) cin >> A[i];for (int i=0; i<30; i++){ll z = 1<<i;set<ll> st;for (int j=0; j<N; j++) st.insert(A[j] / z);bool f=0;for (auto x : st){if (st.count(x/2*2) && st.count(x/2*2+1)) f=1;}x += f;}cout << mint(2).pow(x).val() << endl;return 0;}