結果

問題 No.669 対決!!! 飲み比べ
ユーザー ohreitetsuohreitetsu
提出日時 2018-05-23 16:37:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 817 bytes
コンパイル時間 810 ms
コンパイル使用メモリ 62,636 KB
実行使用メモリ 6,928 KB
最終ジャッジ日時 2023-09-11 01:47:16
合計ジャッジ時間 1,741 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 3 ms
4,628 KB
testcase_11 AC 4 ms
6,912 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 4 ms
6,928 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int getgrundy(int x,vector<int>& groundy,int K)
{
	int subgame=0;
	if (x>K){
		if (groundy[x]!=-1){
			return groundy[x];
		}
		subgame=x%(K+1);//grundyを求める
	}else{
		subgame=min(x,K);
	}
	return groundy[x]=subgame;
}
int salve(vector<int> data,int MAX,int K)
{
	vector<int> grundy(MAX+1,-1);
	vector<int> Grundy(data.size()+1);
	int aw=0;
	for (int i=0;i<data.size();i++){
		Grundy[i]=getgrundy(data[i],grundy,K);
		aw^=Grundy[i];
	}
	if (aw!=0){
		return 1;
	}else{
		return 2;
	}
}
int main()
{
   	int N,K;
	cin>>N>>K;
	vector<int> data;
	int i;
	int MAX=0;
	int A;
	for (i=0;i<N;i++){
		cin>>A;
		if (MAX<A){
			MAX=A;
		}
		data.push_back(A);
	}
	int aw=salve(data,MAX,K);
	if (aw==1){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
    
}
0