結果

問題 No.5001 排他的論理和でランニング
ユーザー treeonetreeone
提出日時 2018-03-17 01:41:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,276 bytes
コンパイル時間 1,147 ms
実行使用メモリ 7,464 KB
スコア 46,111,105
最終ジャッジ日時 2020-03-12 19:52:10
ジャッジサーバーID
(参考情報)
judge6 /
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1,476 ms
5,376 KB
testcase_02 AC 1,469 ms
5,376 KB
testcase_03 AC 1,473 ms
5,380 KB
testcase_04 AC 1,477 ms
6,452 KB
testcase_05 AC 1,476 ms
5,380 KB
testcase_06 AC 1,471 ms
5,380 KB
testcase_07 AC 1,477 ms
5,376 KB
testcase_08 AC 1,481 ms
7,464 KB
testcase_09 AC 1,470 ms
5,376 KB
testcase_10 AC 1,476 ms
5,380 KB
testcase_11 AC 1,475 ms
5,376 KB
testcase_12 AC 1,472 ms
5,380 KB
testcase_13 AC 1,483 ms
6,976 KB
testcase_14 AC 1,477 ms
5,376 KB
testcase_15 AC 1,472 ms
5,376 KB
testcase_16 AC 1,472 ms
5,380 KB
testcase_17 AC 1,473 ms
5,380 KB
testcase_18 WA -
testcase_19 AC 1,473 ms
5,384 KB
testcase_20 AC 1,474 ms
5,376 KB
testcase_21 AC 1,482 ms
5,376 KB
testcase_22 AC 1,473 ms
5,376 KB
testcase_23 AC 1,472 ms
5,380 KB
testcase_24 AC 1,474 ms
5,376 KB
testcase_25 AC 1,473 ms
5,376 KB
testcase_26 AC 1,471 ms
5,380 KB
testcase_27 AC 1,469 ms
5,376 KB
testcase_28 AC 1,476 ms
5,376 KB
testcase_29 AC 1,477 ms
5,376 KB
testcase_30 AC 1,475 ms
5,380 KB
testcase_31 AC 1,478 ms
5,380 KB
testcase_32 AC 1,473 ms
7,420 KB
testcase_33 AC 1,481 ms
7,028 KB
testcase_34 AC 1,479 ms
6,736 KB
testcase_35 AC 1,476 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,473 ms
5,376 KB
testcase_39 AC 1,476 ms
5,376 KB
testcase_40 AC 1,474 ms
6,148 KB
testcase_41 AC 1,473 ms
5,380 KB
testcase_42 AC 1,476 ms
5,380 KB
testcase_43 AC 1,473 ms
5,380 KB
testcase_44 AC 1,474 ms
5,384 KB
testcase_45 WA -
testcase_46 AC 1,476 ms
5,380 KB
testcase_47 AC 1,476 ms
5,384 KB
testcase_48 AC 1,476 ms
0 KB
testcase_49 AC 1,479 ms
6,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;
unsigned w;
unsigned xor128() {
  static unsigned x = 123456789, y = 362436069, z = 521288629/*, w = 88675123*/;
  unsigned t = (x ^ (x << 11));
  x = y; y = z; z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
class Timer {
private:
  clock_t start;
public:
  Timer() {
    start = clock();
  }
  double sec() {
    clock_t end = clock();
    return (double) (end - start) / CLOCKS_PER_SEC;
  }
};
const double TimeLimit = 1.450;
Timer timer;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    clock_t start, end;
	start = clock();
	random_device rnd;
	mt19937 mt((int)time(0));
    w = mt();
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    sort(all(a));
    // vector<int> ans;
    set<int> st;
    int now = 0;
    repb(i, n - 1, 0){
        if(now ^ a[i] > now){
            now ^= a[i];
            // ans.push_back(i);
            st.insert(i);
        }
        if(st.size() == m) break;
    }
    int sz = m - st.size();
    rep(i, 0, n){
        if(st.size() == m) break;
        if(st.count(a[i])){
            now ^= a[i];
            // ans.push_back(i);
            st.insert(i);
        }
    }
	while(1){
		double tmp = timer.sec();
		if(tmp > TimeLimit){
			break;
        }
        int id = xor128() % n;
        int id2 = xor128() % n;
        if(!(st.count(id) ^ st.count(id2))) continue;
        if(st.count(id2)) swap(id, id2); 
        int tmp2 = now ^ a[id] ^ a[id2];
        if(tmp2 > now){
            now = tmp2;
            st.erase(id);
            st.insert(id2);
        }
		// if((int)(tmp * 1000) % 100 <= 20){
		// 	cerr << tmp << " " << now << endl;
		// }
    }
    int sum = 0;
    for(auto it = st.begin(); it != st.end(); it++){
        if(it != st.begin()) cout << ' ';
        cout << a[*it];
        sum ^= a[*it];
    }
    cout << endl;
    cerr << now << " " << sum << endl;
}
0