結果

問題 No.8 N言っちゃダメゲーム
ユーザー fushime2fushime2
提出日時 2018-03-01 07:00:50
言語 D
(dmd 2.106.1)
結果
RE  
実行時間 -
コード長 774 bytes
コンパイル時間 710 ms
コンパイル使用メモリ 85,868 KB
実行使用メモリ 11,300 KB
最終ジャッジ日時 2023-09-03 18:52:12
合計ジャッジ時間 9,305 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std.stdio, std.algorithm, std.string, std.string, std.conv, std.array;

int readint() { return readln.chomp.to!int; }
auto readints() { return readln.split.map!(to!int); }

int n, k;

int[100010][2] dp;

int rec(int i, int s) {
    if (dp[!(i&1)][s] != -1) return dp[!(i&1)][s];
    if (s >= n) return dp[!(i&1)][s] = !(i & 1);

    int r = rec(i+1, s+1);
    foreach(t; s+2..s+k+1) if (t < n) {
        int nxt = rec(i+1, t);
        if (i & 1) r &= nxt;
        else r |= nxt;
    }
    return dp[!(i&1)][s] = r;
}


void main() {
    int p = readint();
    foreach(_; 0..p) {
        auto nk = readints();
        n = nk[0], k = nk[1];
        foreach(i; 0..2) dp[i][0..$] = -1;
        writeln(rec(0, 0) ? "Win" : "Lose");
    }

    string _ = readln(); // dbg
}
0