結果
問題 |
No.2658 L-R Nim
|
ユーザー |
![]() |
提出日時 | 2024-03-01 22:21:13 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,157 bytes |
コンパイル時間 | 7,134 ms |
コンパイル使用メモリ | 265,136 KB |
最終ジャッジ日時 | 2025-02-19 22:45:57 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 39 WA * 3 TLE * 6 |
ソースコード
#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"; } 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"; }