結果
問題 |
No.2658 L-R Nim
|
ユーザー |
![]() |
提出日時 | 2024-03-01 22:04:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,610 bytes |
コンパイル時間 | 1,966 ms |
コンパイル使用メモリ | 196,344 KB |
最終ジャッジ日時 | 2025-02-19 22:32:22 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 2 |
other | AC * 9 WA * 17 TLE * 1 -- * 21 |
ソースコード
#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; 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"; }