結果
問題 |
No.8 N言っちゃダメゲーム
|
ユーザー |
![]() |
提出日時 | 2015-01-08 00:48:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 697 bytes |
コンパイル時間 | 892 ms |
コンパイル使用メモリ | 80,816 KB |
実行使用メモリ | 87,756 KB |
最終ジャッジ日時 | 2024-06-13 02:58:13 |
合計ジャッジ時間 | 7,095 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 TLE * 1 -- * 7 |
ソースコード
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <set> #include <cmath> using namespace std; int grundy(vector<int> &memo, int x, const int &N, const int &K){ if(memo[x] >= 0) return memo[x]; set<int> s; for(int i=1; i<=K; i++){ if(x+i >= N) break; s.insert( grundy(memo, x+i, N, K) ); } int ret = 0; while( s.count(ret) != 0 ) ret++; memo[x] = ret; return ret; } void solve(){ int N,K; cin >> N >> K; vector<int> memo(N+1, -1); cout << (grundy(memo,0,N,K) != 0? "Win":"Lose") << endl; } int main(){ int N; cin >> N; for(int i=0; i<N; i++){ solve(); } return 0; }