結果
| 問題 |
No.5001 排他的論理和でランニング
|
| ユーザー |
emthrm
|
| 提出日時 | 2020-03-16 04:05:00 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,407 ms / 1,500 ms |
| コード長 | 2,510 bytes |
| コンパイル時間 | 3,296 ms |
| 実行使用メモリ | 7,480 KB |
| スコア | 52,360,054 |
| 最終ジャッジ日時 | 2020-03-16 04:06:21 |
|
ジャッジサーバーID (参考情報) |
judge10 / |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
IOSetup() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} iosetup;
struct Timer {
Timer() { reset(); }
void reset() { beg = chrono::high_resolution_clock::now(); }
ll elapsed() {
chrono::high_resolution_clock::time_point en = chrono::high_resolution_clock::now();
return chrono::duration_cast<chrono::milliseconds>(en - beg).count();
}
private:
chrono::high_resolution_clock::time_point beg;
} timer;
struct Xor128 {
int rand() {
unsigned t = x ^ (x << 11);
x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
return static_cast<int>(w);
}
int rand(int ub) {
int res = rand() % ub;
return res < 0 ? res + ub : res;
}
int rand(int lb, int ub) { return lb + rand(ub - lb); }
ll randll() {
unsigned long long res = static_cast<unsigned long long>(rand()) << 32;
return static_cast<ll>(res | rand());
}
ll randll(ll ub) {
ll res = randll() % ub;
return res < 0 ? res + ub : res;
}
ll randll(ll lb, ll ub) { return lb + randll(ub - lb); }
private:
unsigned x = 123456789, y = 362436069, z = 521288629, w = static_cast<unsigned>(time(nullptr));
} xor128;
int main() {
int n, m; cin >> n >> m;
vector<int> a(n); REP(i, n) cin >> a[i];
int score = 0;
REP(i, m) score ^= a[i];
vector<int> ans(a.begin(), a.begin() + m);
while (timer.elapsed() < 1400) {
int x = 0;
vector<int> as;
vector<bool> v(n, false);
while (timer.elapsed() < 1400 && as.size() < m) {
int idx = xor128.rand(n);
if (!v[idx]) {
x ^= a[idx];
as.emplace_back(a[idx]);
v[idx] = true;
}
}
if (x > score) {
score = x;
ans = as;
}
}
REP(i, m) cout << ans[i] << " \n"[i + 1 == m];
return 0;
}
emthrm