結果

問題 No.8 N言っちゃダメゲーム
ユーザー outlineoutline
提出日時 2021-01-23 20:19:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,447 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 136,124 KB
実行使用メモリ 11,496 KB
最終ジャッジ日時 2023-08-30 04:41:54
合計ジャッジ時間 8,029 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 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 <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

void solve(){
    int N, K;
    cin >> N >> K;
    vector<int> dp(N + 1, -1);
    auto func = [&](auto&& self, int i) -> int {
        if(dp[i] != -1) return dp[i];
        if(i == N)  return dp[i] = 1;
        int res = 0;
        for(int j = 1; j <= min(K, N - i); ++j){
            res |= self(self, i + j) ^ 1;
        }
        return dp[i] = res;
    };
    cout << (func(func, 0) ? "Win\n" : "Lose\n");
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--)  solve();

    return 0;
}
0