結果
問題 |
No.361 門松ゲーム2
|
ユーザー |
![]() |
提出日時 | 2018-12-06 16:03:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 708 ms / 2,000 ms |
コード長 | 728 bytes |
コンパイル時間 | 2,161 ms |
コンパイル使用メモリ | 198,756 KB |
最終ジャッジ日時 | 2025-01-06 18:24:51 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE Int dp[555]; Int dfs(Int x,Int d){ Int &res=dp[x]; if(~res) return res; res=0; set<Int> ss; for(Int a=1;a<x;a++){ for(Int b=1;b<a&&a+b<x;b++){ Int c=x-(a+b); if(a==c||b==c) continue; if(max({a,b,c})-min({a,b,c})>d) continue; ss.emplace(dfs(a,d)^dfs(b,d)^dfs(c,d)); } } while(ss.count(res)) res++; return res; } signed main(){ Int l,d; cin>>l>>d; memset(dp,-1,sizeof(dp)); cout<<(dfs(l,d)?"kado":"matsu")<<endl; return 0; }