結果
問題 | No.5001 排他的論理和でランニング |
ユーザー | alpha_virginis |
提出日時 | 2018-03-16 23:32:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,366 ms / 1,500 ms |
コード長 | 2,808 bytes |
コンパイル時間 | 2,367 ms |
実行使用メモリ | 5,724 KB |
スコア | 52,424,951 |
最終ジャッジ日時 | 2020-03-12 19:36:51 |
ジャッジサーバーID (参考情報) |
judge7 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,363 ms
5,392 KB |
testcase_01 | AC | 1,357 ms
3,968 KB |
testcase_02 | AC | 1,359 ms
4,160 KB |
testcase_03 | AC | 1,361 ms
4,352 KB |
testcase_04 | AC | 1,365 ms
5,724 KB |
testcase_05 | AC | 1,360 ms
4,512 KB |
testcase_06 | AC | 1,360 ms
4,412 KB |
testcase_07 | AC | 1,361 ms
4,536 KB |
testcase_08 | AC | 1,366 ms
5,212 KB |
testcase_09 | AC | 1,357 ms
4,024 KB |
testcase_10 | AC | 1,361 ms
4,080 KB |
testcase_11 | AC | 1,362 ms
4,352 KB |
testcase_12 | AC | 1,359 ms
4,260 KB |
testcase_13 | AC | 1,366 ms
5,084 KB |
testcase_14 | AC | 1,362 ms
4,372 KB |
testcase_15 | AC | 1,360 ms
4,444 KB |
testcase_16 | AC | 1,359 ms
3,984 KB |
testcase_17 | AC | 1,360 ms
4,140 KB |
testcase_18 | AC | 1,361 ms
4,596 KB |
testcase_19 | AC | 1,360 ms
4,204 KB |
testcase_20 | AC | 1,360 ms
4,112 KB |
testcase_21 | AC | 1,360 ms
4,220 KB |
testcase_22 | AC | 1,359 ms
4,112 KB |
testcase_23 | AC | 1,359 ms
3,940 KB |
testcase_24 | AC | 1,359 ms
4,148 KB |
testcase_25 | AC | 1,359 ms
4,604 KB |
testcase_26 | AC | 1,359 ms
4,568 KB |
testcase_27 | AC | 1,359 ms
4,360 KB |
testcase_28 | AC | 1,362 ms
4,496 KB |
testcase_29 | AC | 1,362 ms
5,104 KB |
testcase_30 | AC | 1,359 ms
4,208 KB |
testcase_31 | AC | 1,362 ms
4,832 KB |
testcase_32 | AC | 1,360 ms
4,152 KB |
testcase_33 | AC | 1,366 ms
5,444 KB |
testcase_34 | AC | 1,365 ms
5,536 KB |
testcase_35 | AC | 1,362 ms
4,792 KB |
testcase_36 | AC | 1,363 ms
4,884 KB |
testcase_37 | AC | 1,361 ms
4,588 KB |
testcase_38 | AC | 1,360 ms
4,108 KB |
testcase_39 | AC | 1,361 ms
4,232 KB |
testcase_40 | AC | 1,360 ms
5,380 KB |
testcase_41 | AC | 1,359 ms
5,384 KB |
testcase_42 | AC | 1,361 ms
5,380 KB |
testcase_43 | AC | 1,361 ms
5,376 KB |
testcase_44 | AC | 1,363 ms
5,380 KB |
testcase_45 | AC | 1,363 ms
5,376 KB |
testcase_46 | AC | 1,360 ms
5,384 KB |
testcase_47 | AC | 1,360 ms
5,376 KB |
testcase_48 | AC | 1,360 ms
5,380 KB |
testcase_49 | AC | 1,364 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using Int = int64_t; using UInt = uint64_t; using C = std::complex<double>; #define rep(i, n) for(Int i = 0; i < (Int)(n); ++i) #define guard(x) if( not (x) ) continue; #ifndef LOCAL_ #define fprintf if( false ) fprintf #endif const double timeLimit = 1.2; struct Timer { static const uint64_t ClocksPerSecond = 2600000000; bool valid; uint64_t beginTime; uint64_t rdtsc() { uint64_t u, l; __asm__ volatile ("rdtsc" : "=a" (l), "=d" (u)); return ((u << 32) | l); } void start() { beginTime = rdtsc(); valid = true; } double getTime() { uint64_t now = rdtsc(); return (double)(now - beginTime) / ClocksPerSecond; } void stop() { valid = false; } } globalTimer; struct Solver { Int n, m; std::vector<Int> xs; void read() { std::cin >> n >> m; xs.clear(); xs.resize(n); rep(i,n) std::cin >> xs[i]; } void gen(int seed) { std::mt19937 mt(seed); std::uniform_int_distribution<> distN(5,100000); n = distN(mt); std::uniform_int_distribution<> distM(1,n); m = distM(mt); std::uniform_int_distribution<> distX(1,1000000); std::vector<bool> checked(1000001); xs.clear(); rep(i,n) { Int x; do { x = distX(mt); } while( checked[x] ); xs.emplace_back(x); } } Int best = 0; std::vector<Int> ans; std::vector<Int> ys,zs; void solve() { for(Int i = 0; i < m; ++i) { ys.emplace_back(i); } for(Int i = m; i < n; ++i) { zs.emplace_back(i); } Int v = 0; for(Int i : ys) { v ^= xs[i]; } fprintf(stderr, "v=%ld\n", v); std::mt19937 mt(314159); std::uniform_int_distribution<> distI(0,m-1); std::uniform_int_distribution<> distK(0,n-m-1); std::uniform_real_distribution<> distP(0.0,1.0); for(Int iter = 0; ; ++iter) { if( globalTimer.getTime() > timeLimit ) break; Int i = distI(mt); Int k = distK(mt); Int nv = v ^ xs[ys[i]] ^ xs[zs[k]]; double prob = v < nv ? 1.0 : exp(-1.0/f(globalTimer.getTime()/timeLimit)); if( distP(mt) <= prob ) { v = nv; std::swap(ys[i], zs[k]); fprintf(stderr, "nv = %ld\n", nv); } if( best < v ) { ans = ys; } } } double f(double x) { double a = 1.0; return -a * x + a; } void write() { printf("%ld", xs[ans[0]]); for(Int i = 1; i < m; ++i) { printf(" %ld", xs[ans[i]]); } putchar('\n'); } }; int main() { globalTimer.start(); Solver solver; solver.read(); //solver.gen(2); solver.solve(); solver.write(); }