結果
問題 |
No.2024 Xer
|
ユーザー |
|
提出日時 | 2022-07-29 23:25:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,630 bytes |
コンパイル時間 | 2,158 ms |
コンパイル使用メモリ | 201,580 KB |
最終ジャッジ日時 | 2025-01-30 15:46:59 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 36 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template <class T> using V = vector<T>; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, X; cin >> N >> X; V<int> A(N); for (auto &a : A) cin >> a; sort(A.begin(), A.end()); A.erase(unique(A.begin(), A.end()), A.end()); if (A.size() != N) { cout << "No" << '\n'; return 0; } auto rec = [&X](auto f, V<int> &A, int b) -> bool { show(A, b); if (b < 0) return true; if (X >> b & 1) { V<int> L, R; for (auto a : A) { if (a >> b & 1) { R.push_back(a); } else { L.push_back(a); } } if (abs((int)L.size() - (int)R.size()) > 1) { return false; } bool res = true; if (L.size() > 0) res &= f(f, L, b - 1); if (R.size() > 0) res &= f(f, R, b - 1); return res; } else { V<int> L, R; for (auto a : A) { if (a >> b & 1) { R.push_back(a); } else { L.push_back(a); } } bool res = true; if (L.size() > 0) res &= f(f, L, b - 1); if (R.size() > 0) res &= f(f, R, b - 1); return res; } }; cout << (rec(rec, A, 30) ? "Yes" : "No") << '\n'; return 0; }