結果

問題 No.2658 L-R Nim
ユーザー 👑 kmjpkmjp
提出日時 2024-03-03 22:28:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,973 ms / 7,000 ms
コード長 1,398 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 209,068 KB
実行使用メモリ 481,472 KB
最終ジャッジ日時 2024-03-03 22:29:36
合計ジャッジ時間 86,932 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,616 KB
testcase_01 AC 3 ms
7,616 KB
testcase_02 AC 3 ms
7,616 KB
testcase_03 AC 3 ms
7,616 KB
testcase_04 AC 3 ms
7,616 KB
testcase_05 AC 331 ms
85,696 KB
testcase_06 AC 419 ms
85,696 KB
testcase_07 AC 333 ms
85,696 KB
testcase_08 AC 331 ms
85,696 KB
testcase_09 AC 426 ms
85,696 KB
testcase_10 AC 399 ms
85,696 KB
testcase_11 AC 402 ms
85,696 KB
testcase_12 AC 424 ms
85,696 KB
testcase_13 AC 412 ms
85,696 KB
testcase_14 AC 409 ms
85,696 KB
testcase_15 AC 335 ms
85,696 KB
testcase_16 AC 416 ms
85,696 KB
testcase_17 AC 415 ms
85,696 KB
testcase_18 AC 426 ms
85,696 KB
testcase_19 AC 410 ms
85,696 KB
testcase_20 AC 352 ms
85,696 KB
testcase_21 AC 437 ms
85,696 KB
testcase_22 AC 416 ms
85,696 KB
testcase_23 AC 332 ms
85,696 KB
testcase_24 AC 376 ms
85,696 KB
testcase_25 AC 2,967 ms
481,472 KB
testcase_26 AC 2,094 ms
481,472 KB
testcase_27 AC 2,958 ms
481,472 KB
testcase_28 AC 2,816 ms
481,472 KB
testcase_29 AC 2,602 ms
481,472 KB
testcase_30 AC 2,322 ms
481,472 KB
testcase_31 AC 2,197 ms
481,472 KB
testcase_32 AC 2,846 ms
481,472 KB
testcase_33 AC 1,703 ms
293,056 KB
testcase_34 AC 2,887 ms
481,472 KB
testcase_35 AC 1,452 ms
309,056 KB
testcase_36 AC 2,890 ms
481,472 KB
testcase_37 AC 1,550 ms
354,112 KB
testcase_38 AC 2,937 ms
481,472 KB
testcase_39 AC 2,929 ms
481,472 KB
testcase_40 AC 2,851 ms
481,472 KB
testcase_41 AC 2,826 ms
481,472 KB
testcase_42 AC 2,885 ms
481,472 KB
testcase_43 AC 2,865 ms
481,472 KB
testcase_44 AC 2,865 ms
481,472 KB
testcase_45 AC 2,902 ms
481,472 KB
testcase_46 AC 2,963 ms
481,472 KB
testcase_47 AC 2,922 ms
481,472 KB
testcase_48 AC 2,727 ms
481,472 KB
testcase_49 AC 2,703 ms
481,472 KB
testcase_50 AC 2,737 ms
481,472 KB
testcase_51 AC 2,921 ms
481,472 KB
testcase_52 AC 2,973 ms
481,472 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];
set<int> S[50505];
set<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.insert(A[i]^(A[i]+j));
		}
	}
	
	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