結果
| 問題 |
No.669 対決!!! 飲み比べ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-23 16:22:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 802 bytes |
| コンパイル時間 | 1,653 ms |
| コンパイル使用メモリ | 72,252 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-06-28 16:17:56 |
| 合計ジャッジ時間 | 1,852 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 23 WA * 1 RE * 1 |
ソースコード
#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=K;
}
return groundy[x]=subgame;
}
int salve(vector<int> data,int MAX,int K)
{
vector<int> grundy(MAX+1,-1);
vector<int> Grundy(MAX+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;
}
}