結果

問題 No.2658 L-R Nim
ユーザー RubikunRubikun
提出日時 2024-03-01 22:04:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,703 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 207,892 KB
実行使用メモリ 20,516 KB
最終ジャッジ日時 2024-03-01 22:08:23
合計ジャッジ時間 31,011 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
19,712 KB
testcase_01 AC 5 ms
11,512 KB
testcase_02 AC 8 ms
19,712 KB
testcase_03 AC 5 ms
11,512 KB
testcase_04 AC 4 ms
11,512 KB
testcase_05 AC 16 ms
19,840 KB
testcase_06 AC 5 ms
11,640 KB
testcase_07 AC 18 ms
19,840 KB
testcase_08 AC 142 ms
19,840 KB
testcase_09 AC 83 ms
19,840 KB
testcase_10 AC 6 ms
11,640 KB
testcase_11 AC 33 ms
19,840 KB
testcase_12 AC 6 ms
11,640 KB
testcase_13 AC 6 ms
11,640 KB
testcase_14 AC 6 ms
11,640 KB
testcase_15 AC 111 ms
19,840 KB
testcase_16 AC 6 ms
11,640 KB
testcase_17 AC 60 ms
19,840 KB
testcase_18 AC 51 ms
19,840 KB
testcase_19 AC 6 ms
11,640 KB
testcase_20 AC 35 ms
19,840 KB
testcase_21 AC 6 ms
11,640 KB
testcase_22 AC 6 ms
11,640 KB
testcase_23 AC 28 ms
19,840 KB
testcase_24 AC 51 ms
19,840 KB
testcase_25 AC 4,591 ms
20,516 KB
testcase_26 AC 4,974 ms
20,516 KB
testcase_27 AC 3,199 ms
20,516 KB
testcase_28 AC 3,962 ms
20,516 KB
testcase_29 AC 173 ms
20,516 KB
testcase_30 AC 93 ms
20,516 KB
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 8 ms
12,076 KB
testcase_34 AC 1,924 ms
20,516 KB
testcase_35 AC 1,317 ms
20,212 KB
testcase_36 AC 1,950 ms
20,516 KB
testcase_37 AC 9 ms
12,156 KB
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 AC 1,902 ms
20,516 KB
testcase_49 AC 94 ms
20,516 KB
testcase_50 TLE -
testcase_51 TLE -
testcase_52 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=1<<20,INF=1<<30;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")


int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,K;cin>>N>>K;
    vector<ll> A(N),rui(N+1);
    for(int i=0;i<N;i++){
        cin>>A[i];
        rui[i+1]=rui[i]^A[i];
    }
    
    ll L=-1,R=N;
    
    vector<ll> la(MAX,-1);
    
    for(ll i=0;i<=N;i++){
        if(la[rui[i]]!=-1){
            chmax(L,la[rui[i]]+1);
            chmin(R,i);
        }
        la[rui[i]]=i;
    }
    
    if(L==-1){
        cout<<"Yes\n";
        return 0;
    }
    
    if(L>R){
        cout<<"No\n";
        return 0;
    }
    
    vector<ll> cn(MAX);
    for(ll i=0;i<L;i++){
        for(ll j=L;j<=N;j++){
            cn[rui[i]^rui[j]]++;
        }
    }
    
    //cout<<L<<" "<<R<<endl;
    
    for(ll s=L;s<=R;s++){
        for(ll x=max(1LL,A[s-1]-K);x<=A[s-1]+K;x++){
            ll z=A[s-1]^x;
            if(cn[z]==0){
                //cout<<s<<" "<<x<<" "<<z<<endl;
                cout<<"Yes\n";
                return 0;
            }
        }
        
        for(ll i=0;i<s;i++) cn[rui[i]^rui[s]]--;
        for(ll i=s+1;i<=N;i++) cn[rui[i]^rui[s]]++;
    }
    
    cout<<"No\n";
}

0