結果
| 問題 |
No.8 N言っちゃダメゲーム
|
| ユーザー |
たこし
|
| 提出日時 | 2015-07-27 20:50:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,490 bytes |
| コンパイル時間 | 838 ms |
| コンパイル使用メモリ | 92,100 KB |
| 実行使用メモリ | 20,000 KB |
| 最終ジャッジ日時 | 2024-07-16 04:14:20 |
| 合計ジャッジ時間 | 7,105 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 TLE * 1 -- * 7 |
ソースコード
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>
#define INF 100000007
#define INF_MAX 2147483647
#define LL_MAX 9223372036854775807
#define EPS 1e-10
#define PI acos(-1)
#define LL long long
using namespace std;
#define MAX_N 120001
#define MAX_K 120001
int N, K;
int memo[MAX_N][2]; //memo[i][j]: jにiの数が回ってきた時にjが勝てるか
int solve(int pos, int turn){
if(memo[pos][turn] != 0){
return memo[pos][turn];
}
if(pos == N){
return memo[pos][turn] = 1;
}
bool flag = false;
int nextTurn = (turn + 1) % 2;
for(int i = 1; i <= K; i++){
int nextP = pos + i;
if(nextP > N)
break;
if(solve(nextP, nextTurn) == -1){
flag = true;
}
}
if(flag){
return memo[pos][turn] = 1;
}
else{
return memo[pos][turn] = -1;
}
}
int main(){
int P;
cin >> P;
for(int i = 0; i < P; i++){
memset(memo, 0, sizeof(memo));
cin >> N >> K;
if(solve(0, 0) == 1){
cout << "Win" << endl;
}
else{
cout << "Lose" << endl;
}
}
return 0;
}
たこし