結果

問題 No.2658 L-R Nim
ユーザー 👑 NachiaNachia
提出日時 2024-03-02 00:07:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6,970 ms / 7,000 ms
コード長 1,179 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 77,976 KB
実行使用メモリ 7,960 KB
最終ジャッジ日時 2024-03-02 00:09:14
合計ジャッジ時間 125,035 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,704 KB
testcase_01 AC 4 ms
7,392 KB
testcase_02 AC 6 ms
7,704 KB
testcase_03 AC 4 ms
7,392 KB
testcase_04 AC 5 ms
7,704 KB
testcase_05 AC 16 ms
7,704 KB
testcase_06 AC 6 ms
7,456 KB
testcase_07 AC 18 ms
7,704 KB
testcase_08 AC 122 ms
7,704 KB
testcase_09 AC 69 ms
7,704 KB
testcase_10 AC 6 ms
7,456 KB
testcase_11 AC 31 ms
7,704 KB
testcase_12 AC 7 ms
7,456 KB
testcase_13 AC 7 ms
7,456 KB
testcase_14 AC 6 ms
7,456 KB
testcase_15 AC 107 ms
7,704 KB
testcase_16 AC 7 ms
7,456 KB
testcase_17 AC 53 ms
7,704 KB
testcase_18 AC 48 ms
7,704 KB
testcase_19 AC 6 ms
7,456 KB
testcase_20 AC 30 ms
7,704 KB
testcase_21 AC 6 ms
7,456 KB
testcase_22 AC 7 ms
7,456 KB
testcase_23 AC 26 ms
7,704 KB
testcase_24 AC 45 ms
7,704 KB
testcase_25 AC 3,493 ms
7,840 KB
testcase_26 AC 3,842 ms
7,840 KB
testcase_27 AC 2,700 ms
7,840 KB
testcase_28 AC 3,507 ms
7,840 KB
testcase_29 AC 154 ms
7,840 KB
testcase_30 AC 89 ms
7,840 KB
testcase_31 AC 6,568 ms
7,840 KB
testcase_32 AC 6,490 ms
7,840 KB
testcase_33 AC 13 ms
7,628 KB
testcase_34 AC 1,687 ms
7,840 KB
testcase_35 AC 1,221 ms
7,960 KB
testcase_36 AC 1,723 ms
7,840 KB
testcase_37 AC 17 ms
7,752 KB
testcase_38 AC 6,743 ms
7,840 KB
testcase_39 AC 6,783 ms
7,840 KB
testcase_40 AC 6,919 ms
7,840 KB
testcase_41 AC 6,826 ms
7,840 KB
testcase_42 AC 6,733 ms
7,840 KB
testcase_43 AC 6,796 ms
7,840 KB
testcase_44 AC 6,871 ms
7,840 KB
testcase_45 AC 6,970 ms
7,840 KB
testcase_46 AC 6,749 ms
7,840 KB
testcase_47 AC 6,791 ms
7,840 KB
testcase_48 AC 1,681 ms
7,840 KB
testcase_49 AC 89 ms
7,840 KB
testcase_50 AC 6,635 ms
7,840 KB
testcase_51 AC 6,653 ms
7,840 KB
testcase_52 AC 6,892 ms
7,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// N^2

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

int main(){
    int MAX_XOR = 1 << 20;
    int N, K; cin >> N >> K;
    vector<int> A(N); rep(i,N) cin >> A[i];
    vector<int> XOR(N+1);
    rep(i,N) XOR[i+1] = XOR[i] ^ A[i];
    int l = 0, r = N; {
        vector<int> 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<int> C(1048576);
    for(int i=0; i<=l; i++) for(int j=l+1; j<=N; j++) C[XOR[i]^XOR[j]]++;
    for(int p=l; p<r; p++){
        if(p != l){
            for(int i=0; i<p; i++) C[XOR[i]^XOR[p]]--;
            for(int i=p+1; i<=N; i++) C[XOR[p]^XOR[i]]++;
        }
        for(int d=-min(A[p],K); d<=K; d++){
            int dx = A[p] ^ (A[p] + d);
            if(C[dx] == 0){ cout << "Yes\n"; return 0; }
        }
    }
    cout << "No\n";
    return 0;
}
0