結果

問題 No.8 N言っちゃダメゲーム
ユーザー KuphonyKuphony
提出日時 2016-03-17 18:03:01
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 893 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 62,524 KB
実行使用メモリ 9,876 KB
最終ジャッジ日時 2024-04-08 16:44:29
合計ジャッジ時間 6,994 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#define MAX 10000
using namespace std;


int main(int argc, const char * argv[]) {
    int P;
    cin >> P;
    int array[P][2];
    for (int i = 0; i < P*2; i++) {
        cin >> array[i/2][i%2];
    }
    for (int x = 0; x < P; x++) {
        int n = array[x][0];
        int k = array[x][1];
        if(n <= k){cout << "Win\n";continue;}
        //動的計画法で解く
        bool dp[n];
        //初期化
        for (int i = 0; i <= n; i++) {
            dp[i] = false;
        }
        dp[0] = true;
        //埋めていく
        for (int i = 0; i <= n; i++) {
            for (int j = 1; j <= k; j++) {
                if(i - j < 0)break;
                dp[i] |= !dp[i - j];
            }
        }
        if(dp[n])cout << "Win\n";
        else cout << "Lose\n";
        }
    }
0