結果

問題 No.8 N言っちゃダメゲーム
ユーザー vrjfsyivrjfsyi
提出日時 2018-03-24 21:11:29
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 928 bytes
コンパイル時間 3,117 ms
コンパイル使用メモリ 76,252 KB
実行使用メモリ 8,588 KB
最終ジャッジ日時 2023-09-07 08:56:11
合計ジャッジ時間 7,794 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;

int main() {

    int P;
    cin >> P;

    int N, K;
    for (int l = 0; l < P; ++l) {
        cin >> N >> K;

        vector<int> v(N + K + 1, 0);
        v[N] = 0;

        set<int> s1;

        for (int k = 0; k <= K; ++k) {
            s1.insert(k);
        }

        for (int i = N - 1; i >= 0; --i) {

            set<int> s2;

            for (int j = 1; j <= K; ++j) {
                s2.insert(v[i + j]);
            }

            set<int> r;
            set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(), std::inserter(r, r.end()));

            v[i] = *r.begin();
        }

        if (v[1] == 0) {
            cout << "Lose" << "\n";
        } else {
            cout << "Win" << "\n";
        }
    }


    return 0;
}

0