結果

問題 No.2658 L-R Nim
ユーザー RubikunRubikun
提出日時 2024-03-01 22:10:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,732 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 209,920 KB
実行使用メモリ 17,856 KB
最終ジャッジ日時 2024-03-01 22:12:49
合計ジャッジ時間 30,267 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
17,656 KB
testcase_01 AC 5 ms
9,596 KB
testcase_02 AC 7 ms
17,656 KB
testcase_03 AC 5 ms
9,596 KB
testcase_04 AC 4 ms
9,596 KB
testcase_05 AC 15 ms
17,692 KB
testcase_06 AC 5 ms
9,632 KB
testcase_07 AC 17 ms
17,692 KB
testcase_08 AC 115 ms
17,692 KB
testcase_09 AC 72 ms
17,692 KB
testcase_10 AC 6 ms
9,632 KB
testcase_11 AC 31 ms
17,692 KB
testcase_12 AC 6 ms
9,632 KB
testcase_13 AC 5 ms
9,632 KB
testcase_14 AC 6 ms
9,632 KB
testcase_15 AC 97 ms
17,692 KB
testcase_16 AC 6 ms
9,632 KB
testcase_17 AC 51 ms
17,692 KB
testcase_18 AC 47 ms
17,692 KB
testcase_19 AC 5 ms
9,632 KB
testcase_20 AC 29 ms
17,692 KB
testcase_21 AC 6 ms
9,632 KB
testcase_22 AC 5 ms
9,632 KB
testcase_23 AC 25 ms
17,692 KB
testcase_24 AC 47 ms
17,692 KB
testcase_25 AC 3,480 ms
17,856 KB
testcase_26 AC 3,861 ms
17,856 KB
testcase_27 AC 2,707 ms
17,856 KB
testcase_28 AC 3,621 ms
17,856 KB
testcase_29 AC 147 ms
17,856 KB
testcase_30 AC 80 ms
17,856 KB
testcase_31 AC 6,862 ms
17,856 KB
testcase_32 AC 6,529 ms
17,856 KB
testcase_33 AC 8 ms
9,716 KB
testcase_34 AC 1,743 ms
17,856 KB
testcase_35 AC 1,279 ms
17,784 KB
testcase_36 AC 1,679 ms
17,856 KB
testcase_37 AC 9 ms
9,744 KB
testcase_38 AC 6,867 ms
17,856 KB
testcase_39 AC 6,867 ms
17,856 KB
testcase_40 AC 6,933 ms
17,856 KB
testcase_41 AC 6,842 ms
17,856 KB
testcase_42 AC 6,885 ms
17,856 KB
testcase_43 AC 6,852 ms
17,856 KB
testcase_44 AC 6,855 ms
17,856 KB
testcase_45 AC 6,758 ms
17,856 KB
testcase_46 AC 6,877 ms
17,856 KB
testcase_47 AC 6,867 ms
17,856 KB
testcase_48 AC 1,797 ms
17,856 KB
testcase_49 AC 83 ms
17,856 KB
testcase_50 AC 6,960 ms
17,856 KB
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 cn[MAX];
int A[MAX],rui[MAX];
int la[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>A[i];
        rui[i+1]=rui[i]^A[i];
    }
    
    int L=-1,R=N;
    
    for(int i=0;i<MAX;i++) la[i]=-1;
    
    for(int 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(int i=0;i<L;i++){
        for(int j=L;j<=N;j++){
            cn[rui[i]^rui[j]]++;
        }
    }
    
    //cout<<L<<" "<<R<<endl;
    
    for(int s=L;s<=R;s++){
        int l=max(1,A[s-1]-K),r=A[s-1]+K,y=A[s-1];
        int ans=0;
        for(int x=l;x<=r;x++){
            ans+=(cn[x^y]==0);
        }
        if(ans){
            cout<<"Yes\n";
            return 0;
        }
        
        int z=rui[s];
        for(int i=0;i<s;i++) cn[rui[i]^z]--;
        for(int i=s+1;i<=N;i++) cn[rui[i]^z]++;
    }
    
    cout<<"No\n";
}

0