結果

問題 No.8 N言っちゃダメゲーム
ユーザー hitoyozakehitoyozake
提出日時 2018-06-03 15:00:08
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,410 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 73,704 KB
実行使用メモリ 9,044 KB
最終ジャッジ日時 2023-09-12 21:52:50
合計ジャッジ時間 7,242 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 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 <string>
#include <vector>
#include <map>

int game(int const n, int const k){

    if( n-1 <= k ){
        return 1; //win
    }

    std::map<int, bool> wl;
    
    wl[n-1] = true;

    for( int i = 2; i <= n; ++i ){
        int const m = std::min(k, i);
        wl[n-i]=true;
//        std::cout << "i:"<< i << std::endl;
        for( int j = 1; j <= m; ++j)
        {
  //          std::cout << "****j:" << j << std::endl;
            if(wl[n-i+j]==true){
                wl[n - i] = false;
                break;
            }
        }
    }

    /*std::cout << "**********" << std::endl;
    for(int i = 0; i < n; ++i )
    {
        std::cout << i << ": " << wl[i] << std::endl;
    }
    std::cout << "**********" << std::endl;
    */
    //1-k縺ョ髢薙〒縺ゥ繧後°�シ代▽縺ァ繧ょ享縺。遲九′縺ゅk縺九←縺�縺九�ョ繝√ぉ繝�繧ッ
    for(int i = 1; i <= k; ++i)
    {
        if(wl[i]==true)
            return 1;
    }

    return 0;
}

int main()
{
    std::vector< int > result;
    int p = 0;

    std::cin >> p;

    for( int i = 0; i < p; ++i )
    {
        int n = 0, k = 0;
        std::cin >> n >> k;

        result.push_back(game(n, k));
    }

    for(auto const i: result)
    {
        if( i == 1 )
            std::cout << "Win" << std::endl;
        else
            std::cout << "Lose" << std::endl;
    }
}


0