結果
問題 |
No.8 N言っちゃダメゲーム
|
ユーザー |
![]() |
提出日時 | 2015-01-08 01:53:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,108 bytes |
コンパイル時間 | 623 ms |
コンパイル使用メモリ | 75,972 KB |
実行使用メモリ | 16,436 KB |
最終ジャッジ日時 | 2024-06-13 02:58:41 |
合計ジャッジ時間 | 6,981 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> #include "assert.h" #include <ctime> #include <stdexcept> using namespace std; int N,K; vector<int> memo; int grundy(int x){ try{ memo.at(x); }catch(const out_of_range& err){ cout << "here " << x << endl; } if(memo.at(x)>=0){ return memo.at(x); } //cerr << "grundy " << x << endl; int ret = 0; for(int i=1; i<=K; i++){ if(x+i >= N) break; if(grundy(x+i) == 0){ ret = 1; break; } } try{ memo.at(x); }catch(const out_of_range& err){ cout << "here_ " << x << endl; } memo.at(x) = ret; return ret; } void solve(){ cin >> N >> K; memo = vector<int>(120000+1, -1); int ans = grundy(0); /* for(int i=0; i<=N; i++){ cerr << i << " " << memo[i] << endl; } */ cout << (ans!=0? "Win":"Lose") << endl; } int main(){ //clock_t start,end; //start = clock(); int T; cin >> T; for(int i=0; i<T; i++){ solve(); } //end = clock(); //printf("%d\n", (int)end-start); return 0; }