結果
| 問題 |
No.5001 排他的論理和でランニング
|
| ユーザー |
masakt
|
| 提出日時 | 2018-03-17 03:10:16 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,151 ms / 1,500 ms |
| コード長 | 1,317 bytes |
| コンパイル時間 | 1,991 ms |
| 実行使用メモリ | 7,424 KB |
| スコア | 52,371,833 |
| 最終ジャッジ日時 | 2020-03-12 19:58:47 |
|
ジャッジサーバーID (参考情報) |
judge7 / |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define INLINE inline __attribute__ ((always_inline))
constexpr double TIME_OUT = 1.0;
constexpr double CYCLES_PER_SEC = 2.6 * 1e9;
INLINE int64_t getCycle() {
uint32_t low, high;
__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
return ((int64_t)low) | ((int64_t)high << 32);
}
INLINE static double getTime() { return getCycle() / CYCLES_PER_SEC; }
int main() {
int n, m;
scanf("%d %d", &n, &m);
vector<int> a(n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
random_device seed_gen;
mt19937 engine(seed_gen());
int score = 0;
vector<int> state(n);
iota(all(state), 0);
int bestScore = 0;
vector<int> bestState(m);
double startTime = getTime();
while (TIME_OUT > getTime() - startTime) {
score = 0;
shuffle(all(state), engine);
for (int i = 0; i < m; i++) {
score ^= a[state[i]];
}
if (bestScore < score) {
bestScore = score;
for (int i = 0; i < m; i++) {
bestState[i] = state[i];
}
}
}
for (int i = 0; i < m; i++) {
printf("%d%c", a[bestState[i]], (i + 1 == n ? '\n' : ' '));
}
return 0;
}
masakt