結果
| 問題 | 
                            No.361 門松ゲーム2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             dnish
                         | 
                    
| 提出日時 | 2017-03-02 12:10:35 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 410 ms / 2,000 ms | 
| コード長 | 659 bytes | 
| コンパイル時間 | 1,984 ms | 
| コンパイル使用メモリ | 171,796 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-13 01:16:14 | 
| 合計ジャッジ時間 | 3,174 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 28 | 
ソースコード
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<b)
typedef long long ll;
using namespace std;
int mem[501];
int L,D;
int grundy(int n){
	if(mem[n]!=-1) return mem[n];
	set<int> s;
	REP(i,1,n){
		REP(j,i+1,n){
			int k=n-i-j;
			if(k<1) continue;
			if(i==k||j==k) continue;
			int mx=max(j,k);
			int mn=min(i,k);
			if(mx-mn>D) continue;
			s.insert(grundy(i)^grundy(j)^grundy(k));
		}
	}
	int ret=0;
	while(s.find(ret)!=s.end()){
		ret++;
	}
	return mem[n]=ret;
}
int main(){
	cin>>L>>D;
	memset(mem,-1,sizeof(mem));
	int g=grundy(L);
	p((g!=0)?"kado":"matsu");
	return 0;
}
            
            
            
        
            
dnish