結果
問題 |
No.361 門松ゲーム2
|
ユーザー |
![]() |
提出日時 | 2016-03-23 22:14:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 155 ms / 2,000 ms |
コード長 | 1,273 bytes |
コンパイル時間 | 785 ms |
コンパイル使用メモリ | 98,344 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 21:39:13 |
合計ジャッジ時間 | 1,918 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> #include <functional> #include <set> #include <ctime> #include <random> #include <chrono> using namespace std; template<class T> istream& operator >> (istream& is, vector<T>& vec){for(T& val: vec) is >> val; return is;} template<class T> istream& operator , (istream& is, T& val){ return is >> val;} template<class T> ostream& operator << (ostream& os, const vector<T>& vec){for(int i=0; i<vec.size(); i++) os << vec[i] << (i==vec.size()-1?"":" "); return os;} template<class T> ostream& operator , (ostream& os, const T& val){ return os << " " << val;} template<class T> ostream& operator >> (ostream& os, const T& val){ return os << " " << val;} int main(){ int l,d; cin >> l,d; vector<int> memo(l+1, -1); function<int(int)> grundy = [&](int L){ if(memo[L] != -1) return memo[L]; set<int> s; for(int a=1; a<L; a++){ for(int b=a+1; b<L; b++){ int c = L-(a+b); if(c <= b) continue; if(c-a <= d) s.insert( grundy(a) ^ grundy(b) ^ grundy(c) ); } } int g = 0; while(s.count(g)) g++; return memo[L] = g; }; cout << (grundy(l)==0?"matsu" : "kado" ) << endl; return 0; }