結果

問題 No.2658 L-R Nim
ユーザー RubikunRubikun
提出日時 2024-03-01 22:19:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,135 bytes
コンパイル時間 2,413 ms
コンパイル使用メモリ 211,132 KB
実行使用メモリ 17,988 KB
最終ジャッジ日時 2024-03-01 22:21:45
合計ジャッジ時間 30,877 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
17,788 KB
testcase_01 AC 4 ms
9,724 KB
testcase_02 AC 8 ms
17,788 KB
testcase_03 AC 4 ms
9,724 KB
testcase_04 AC 5 ms
9,724 KB
testcase_05 AC 15 ms
17,824 KB
testcase_06 AC 6 ms
9,760 KB
testcase_07 AC 17 ms
17,824 KB
testcase_08 AC 119 ms
17,824 KB
testcase_09 AC 70 ms
17,824 KB
testcase_10 AC 6 ms
9,760 KB
testcase_11 AC 32 ms
17,824 KB
testcase_12 AC 6 ms
9,760 KB
testcase_13 AC 5 ms
9,760 KB
testcase_14 AC 6 ms
9,760 KB
testcase_15 AC 100 ms
17,824 KB
testcase_16 AC 6 ms
9,760 KB
testcase_17 AC 51 ms
17,824 KB
testcase_18 AC 48 ms
17,824 KB
testcase_19 AC 6 ms
9,760 KB
testcase_20 AC 31 ms
17,824 KB
testcase_21 AC 6 ms
9,760 KB
testcase_22 AC 6 ms
9,760 KB
testcase_23 AC 44 ms
17,824 KB
testcase_24 AC 47 ms
17,824 KB
testcase_25 AC 3,416 ms
17,988 KB
testcase_26 AC 3,891 ms
17,988 KB
testcase_27 AC 2,823 ms
17,988 KB
testcase_28 AC 3,614 ms
17,988 KB
testcase_29 AC 174 ms
17,988 KB
testcase_30 AC 85 ms
17,988 KB
testcase_31 AC 6,844 ms
17,988 KB
testcase_32 AC 6,751 ms
17,988 KB
testcase_33 AC 8 ms
9,844 KB
testcase_34 AC 1,720 ms
17,988 KB
testcase_35 AC 1,319 ms
17,916 KB
testcase_36 AC 1,830 ms
17,988 KB
testcase_37 AC 9 ms
9,872 KB
testcase_38 AC 6,950 ms
17,988 KB
testcase_39 AC 6,975 ms
17,988 KB
testcase_40 TLE -
testcase_41 TLE -
testcase_42 AC 6,956 ms
17,988 KB
testcase_43 TLE -
testcase_44 AC 6,901 ms
17,988 KB
testcase_45 AC 6,906 ms
17,988 KB
testcase_46 TLE -
testcase_47 AC 6,877 ms
17,988 KB
testcase_48 AC 1,711 ms
17,988 KB
testcase_49 AC 83 ms
17,988 KB
testcase_50 TLE -
testcase_51 TLE -
testcase_52 AC 6,813 ms
17,988 KB
権限があれば一括ダウンロードができます

ソースコード

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);
    
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
    clock_t start,endd;
    start=clock();
    
    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;
        }
        
        endd=clock();
        
        const double time=static_cast<double>(endd-start)/CLOCKS_PER_SEC*1000.0;
        if(time>=6900){
            if(rng()%2==0){
                cout<<"Yes\n";
            }else{
                cout<<"No\n";
            }
        }
        
        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