結果

問題 No.8 N言っちゃダメゲーム
ユーザー pekempeypekempey
提出日時 2015-07-25 13:29:28
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,287 bytes
コンパイル時間 1,406 ms
コンパイル使用メモリ 149,744 KB
実行使用メモリ 19,516 KB
最終ジャッジ日時 2023-09-23 04:51:39
合計ジャッジ時間 7,668 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,384 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define itall(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-8;
template<typename T> inline T sq(T a) { return a * a; }
template<typename T> inline T cb(T a) { return a * a * a; }
template<typename T> inline bool umin(T &a, const T &b) { return b < a && (a = b, true); }
template<typename T> inline bool umax(T &a, const T &b) { return a < b && (a = b, true); }

int dp[200000];
int N, K;

int grundy(int k) {
    if (dp[k] >= 0) return dp[k];

    if (k >= N - 1) return dp[k] = 0;

    set<int> s;

    rep (i, K) {
        if (k + i + 1 <= N) {
            s.insert(grundy(k + i + 1));
        }
    }

    int res = 0;
    while (s.count(res)) res++;

    return dp[k] = res;
}

int main() {
    int P;
    cin >> P;

    rep (i, P) {
        cin >> N >> K;
        memset(dp, -1, sizeof(dp));
        if (grundy(0) == 0) {
            cout << "Lose" << endl;
        } else {
            cout << "Win" << endl;
        }
    }
}
0