結果
| 問題 |
No.862 XORでX
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-09 23:15:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,532 bytes |
| コンパイル時間 | 1,950 ms |
| コンパイル使用メモリ | 182,796 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-19 15:46:51 |
| 合計ジャッジ時間 | 5,624 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 TLE * 1 -- * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//引数unzipには圧縮前のvectorを入れる
int compress(vector<ll>& unzip, map<ll, int>& zip) {
sort(unzip.begin(), unzip.end());
unzip.erase(unique(unzip.begin(), unzip.end()), unzip.end());
for (int i = 0; i < unzip.size(); i++) {
zip[unzip[i]] = i;
}
return unzip.size();
}
bool judge(vector<ll>& ans) {
int n = ans.size();
for (ll x : ans) {
if (x <= 0 || x > 100005) return false;
}
map<ll, int> dummy;
return compress(ans, dummy) == n;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, x;
cin >> n >> x;
vector<ll> ans;
map<ll, int> dummy;
mt19937 mt(0);
do {
ans.assign(n, 0);
for (int i = 0; i < 17; i++) {
vector<int> b1(n, 0);
if (x & (1 << i)) {
int cnt = n / 2;
cnt += 1 - cnt % 2;
for (int j = 0; j < cnt; j++) b1[j] = 1;
} else {
int cnt = n / 2;
cnt += cnt % 2;
for (int j = 0; j < cnt; j++) b1[j] = 1;
}
shuffle(b1.begin(), b1.end(), mt);
for (int j = 0; j < n; j++) {
ans[j] |= (b1[j] << i);
}
}
sort(ans.begin(), ans.end());
if (x & (1 << 17)) {
ans[0] |= (1 << 17);
}
} while (!judge(ans));
for (ll x : ans) {
cout << x << "\n";
}
return 0;
}