結果
| 問題 |
No.2061 XOR Sort
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2022-08-26 22:16:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,324 bytes |
| コンパイル時間 | 2,311 ms |
| コンパイル使用メモリ | 219,832 KB |
| 最終ジャッジ日時 | 2025-01-31 05:01:35 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 39 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic pop
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using mint = modint998244353;
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
VI a(n);
rep(i, n) cin >> a[i];
sort(all(a));
auto dfs = [&](auto self, int k, int l, int r) -> mint {
if (k == 0) return 1;
k--;
if (((a[l] ^ a[r-1]) >> k & 1) == 0) return self(self, k, l, r);
int c = lower_bound(a.begin() + l, a.begin() + r, 1 << k, [&](int x, int y) { return (x >> k & 1) < (y >> k & 1); }) - a.begin();
return self(self, k, l, c) * self(self, k, c, r) * 2;
};
mint ans = dfs(dfs, 30, 0, n);
cout << ans.val() << '\n';
}
Kude