結果

問題 No.2658 L-R Nim
ユーザー 👑 kmjpkmjp
提出日時 2024-03-03 22:29:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,377 ms / 7,000 ms
コード長 1,475 bytes
コンパイル時間 2,390 ms
コンパイル使用メモリ 214,160 KB
実行使用メモリ 464,976 KB
最終ジャッジ日時 2024-03-03 22:31:02
合計ジャッジ時間 70,312 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,872 KB
testcase_01 AC 3 ms
7,872 KB
testcase_02 AC 3 ms
7,872 KB
testcase_03 AC 3 ms
7,872 KB
testcase_04 AC 3 ms
7,872 KB
testcase_05 AC 245 ms
83,588 KB
testcase_06 AC 333 ms
83,588 KB
testcase_07 AC 250 ms
83,588 KB
testcase_08 AC 247 ms
83,588 KB
testcase_09 AC 328 ms
83,588 KB
testcase_10 AC 326 ms
83,588 KB
testcase_11 AC 313 ms
83,588 KB
testcase_12 AC 325 ms
83,588 KB
testcase_13 AC 329 ms
83,588 KB
testcase_14 AC 327 ms
83,460 KB
testcase_15 AC 246 ms
83,588 KB
testcase_16 AC 328 ms
83,588 KB
testcase_17 AC 326 ms
83,588 KB
testcase_18 AC 334 ms
83,588 KB
testcase_19 AC 328 ms
83,588 KB
testcase_20 AC 264 ms
83,588 KB
testcase_21 AC 357 ms
83,588 KB
testcase_22 AC 328 ms
83,588 KB
testcase_23 AC 247 ms
83,588 KB
testcase_24 AC 280 ms
83,588 KB
testcase_25 AC 2,377 ms
464,972 KB
testcase_26 AC 1,614 ms
464,972 KB
testcase_27 AC 2,328 ms
464,972 KB
testcase_28 AC 2,270 ms
464,972 KB
testcase_29 AC 2,051 ms
464,972 KB
testcase_30 AC 1,720 ms
464,972 KB
testcase_31 AC 1,675 ms
464,972 KB
testcase_32 AC 2,295 ms
464,972 KB
testcase_33 AC 1,382 ms
284,564 KB
testcase_34 AC 2,321 ms
464,976 KB
testcase_35 AC 1,123 ms
298,408 KB
testcase_36 AC 2,340 ms
464,972 KB
testcase_37 AC 1,089 ms
342,232 KB
testcase_38 AC 2,343 ms
464,972 KB
testcase_39 AC 2,352 ms
464,972 KB
testcase_40 AC 2,377 ms
464,972 KB
testcase_41 AC 2,343 ms
464,972 KB
testcase_42 AC 2,367 ms
464,972 KB
testcase_43 AC 2,356 ms
464,972 KB
testcase_44 AC 2,337 ms
464,972 KB
testcase_45 AC 2,331 ms
464,972 KB
testcase_46 AC 2,351 ms
464,972 KB
testcase_47 AC 2,344 ms
464,972 KB
testcase_48 AC 2,164 ms
464,972 KB
testcase_49 AC 2,217 ms
464,972 KB
testcase_50 AC 2,216 ms
464,972 KB
testcase_51 AC 2,366 ms
464,972 KB
testcase_52 AC 2,351 ms
464,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,K,A[101010];
unordered_set<int> S[50505];
vector<int> cand;
int X[50505];
int M[1<<20];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>A[i];
		X[i+1]=X[i]^A[i];
		for(j=-K;j<=K;j++) if(A[i]+j>=1) {
			S[i].insert(A[i]^(A[i]+j));
			cand.push_back(A[i]^(A[i]+j));
		}
	}
	sort(ALL(cand));
	cand.erase(unique(ALL(cand)),cand.end());
	
	FORR(c,cand) {
		int num=0;
		FOR(i,N+1) {
			if(M[X[i]]++==0) num++;
		}
		
		for(i=N-1;i>=0;i--) {
			if(--M[X[i+1]]==0) num--;
			if(M[X[i+1]^c]++==0) num++;
			if(num==N+1&&S[i].count(c)) {
				cout<<"Yes"<<endl;
				return;
			}
		}
		M[0]--;
		FOR(i,N) M[X[i+1]^c]=0;
	}
	cout<<"No"<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0