結果

問題 No.2658 L-R Nim
ユーザー 👑 NachiaNachia
提出日時 2024-01-31 00:21:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 692 ms / 7,000 ms
コード長 1,704 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 80,028 KB
実行使用メモリ 53,288 KB
最終ジャッジ日時 2024-02-29 02:32:53
合計ジャッジ時間 15,607 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
52,504 KB
testcase_01 AC 7 ms
19,680 KB
testcase_02 AC 20 ms
52,504 KB
testcase_03 AC 7 ms
19,680 KB
testcase_04 AC 20 ms
52,504 KB
testcase_05 AC 56 ms
52,632 KB
testcase_06 AC 9 ms
19,808 KB
testcase_07 AC 53 ms
52,632 KB
testcase_08 AC 78 ms
52,632 KB
testcase_09 AC 50 ms
52,632 KB
testcase_10 AC 10 ms
19,808 KB
testcase_11 AC 51 ms
52,632 KB
testcase_12 AC 9 ms
19,808 KB
testcase_13 AC 9 ms
19,808 KB
testcase_14 AC 9 ms
19,808 KB
testcase_15 AC 59 ms
52,632 KB
testcase_16 AC 9 ms
19,808 KB
testcase_17 AC 40 ms
52,632 KB
testcase_18 AC 46 ms
52,632 KB
testcase_19 AC 9 ms
19,808 KB
testcase_20 AC 53 ms
52,632 KB
testcase_21 AC 10 ms
19,808 KB
testcase_22 AC 10 ms
19,808 KB
testcase_23 AC 29 ms
52,632 KB
testcase_24 AC 42 ms
52,632 KB
testcase_25 AC 412 ms
53,288 KB
testcase_26 AC 426 ms
53,288 KB
testcase_27 AC 374 ms
53,288 KB
testcase_28 AC 426 ms
53,288 KB
testcase_29 AC 225 ms
53,288 KB
testcase_30 AC 210 ms
53,288 KB
testcase_31 AC 595 ms
53,288 KB
testcase_32 AC 598 ms
53,288 KB
testcase_33 AC 17 ms
20,240 KB
testcase_34 AC 135 ms
53,288 KB
testcase_35 AC 284 ms
53,008 KB
testcase_36 AC 139 ms
53,288 KB
testcase_37 AC 124 ms
53,080 KB
testcase_38 AC 620 ms
53,288 KB
testcase_39 AC 602 ms
53,288 KB
testcase_40 AC 607 ms
53,288 KB
testcase_41 AC 620 ms
53,288 KB
testcase_42 AC 600 ms
53,288 KB
testcase_43 AC 637 ms
53,288 KB
testcase_44 AC 631 ms
53,288 KB
testcase_45 AC 615 ms
53,288 KB
testcase_46 AC 614 ms
53,288 KB
testcase_47 AC 692 ms
53,288 KB
testcase_48 AC 138 ms
53,288 KB
testcase_49 AC 213 ms
53,288 KB
testcase_50 AC 596 ms
53,288 KB
testcase_51 AC 611 ms
53,288 KB
testcase_52 AC 614 ms
53,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(i64 i=0; i<(i64)(n); i++)
#define repr(i,n) for(i64 i=(i64)(n)-1; i>=0; i--)

int main(){
    i64 MAX_XOR = (i64)1 << 21;
    i64 N, K; cin >> N >> K;
    vector<i64> A(N); rep(i,N) cin >> A[i];
    vector<i64> XOR(N+1);
    rep(i,N) XOR[i+1] = XOR[i] ^ A[i];
    i64 l = 0, r = N; {
        vector<i64> lastseen(MAX_XOR, -1);
        rep(i,N+1){
            if(lastseen[XOR[i]] != -1){
                l = max(l, lastseen[XOR[i]]);
                r = min(r, i);
            }
            lastseen[XOR[i]] = i;
        }
    }
    if(r <= l){
        cout << "No\n";
        return 0;
    }
    vector<i64> xorcand;
    for(i64 i=0; i<15; i++){
        i64 offset = (((i64(1) << i) - 1) << 7);
        for(i64 d=0; d<128; d++) if((offset | d) < MAX_XOR) xorcand.push_back(offset | d);
    }
    vector<i64> lpos(MAX_XOR);
    vector<i64> rpos(MAX_XOR);
    vector<i64> C(MAX_XOR);
    for(i64 i=0; i<=l; i++) lpos[XOR[i]]++;
    for(i64 i=l+1; i<=N; i++){
        for(i64 x : xorcand) C[x] += lpos[XOR[i] ^ x];
        rpos[XOR[i]]++;
    }
    for(i64 i=l; i<r; i++){
        if(i != l){
            for(i64 x : xorcand) C[x] -= lpos[XOR[i] ^ x];
            rpos[XOR[i]]--;
            lpos[XOR[i]]++;
            for(i64 x : xorcand) C[x] += rpos[XOR[i] ^ x];
        }
        for(i64 d=-min(A[i],K); d<=K; d++){
            i64 dx = A[i] ^ (A[i] + d);
            if(C[dx] == 0){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}
0