結果
| 問題 |
No.5001 排他的論理和でランニング
|
| ユーザー |
|
| 提出日時 | 2023-08-27 18:27:11 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 629 bytes |
| コンパイル時間 | 3,089 ms |
| コンパイル使用メモリ | 246,476 KB |
| 実行使用メモリ | 4,504 KB |
| スコア | 0 |
| 最終ジャッジ日時 | 2023-08-27 18:27:20 |
| 合計ジャッジ時間 | 8,054 ms |
|
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 50 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n), c(n);
for (int i = 0; i < n; i++) cin >> a[i];
vector<int> b(m);
iota(b.begin(), b.end(), 0);
for (int i = 0; i < m; i++) c[i] = 1;
int nsc = 0;
for (int i: a) nsc ^= i;
random_device rd;
mt19937 mt(rd());
for (int i = 0; i < 50000; i++) {
// b[x]をa[y]に変える
int x = mt() % m, y = mt() % n;
int newsc = nsc ^ a[x] ^ a[y];
if (newsc > nsc && c[y] == 0) {
nsc = newsc;
b[x] = y;
c[x] = 0;
c[y] = 1;
}
}
for (int i = 0; i < m - 1; i++) cout << b[i] << ' ';
cout << b[m - 1] << '\n';
}