結果

問題 No.8 N言っちゃダメゲーム
ユーザー edge2992edge2992
提出日時 2022-09-14 08:39:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 716 bytes
コンパイル時間 2,862 ms
コンパイル使用メモリ 204,280 KB
実行使用メモリ 24,440 KB
最終ジャッジ日時 2023-08-21 07:48:15
合計ジャッジ時間 8,822 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 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 <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Int long long

int getgrundy(int x, vector<int> & grundy, int N, int K){
  if(grundy[x] != -1) return grundy[x];
  set<int> Set;
  for(int i=x+1; i <= min(x+K, N-1); i++){
    Set.insert(getgrundy(i, grundy, N, K));
  }
  int subgame = 0;
  while(Set.count(subgame)) subgame++;
  return grundy[x] = subgame;
}

void solve(){
  int N, K;
  cin >> N >> K;
  vector<int> grundy(N, -1);
  grundy[N-1] = 0;
  int gameval = getgrundy(0, grundy, N, K);
  if(gameval){
    cout << "Win" << endl;
  }else{
    cout << "Lose" << endl;
  }
}

int main() {
  int P;
  cin >> P;
  rep(i, P){
    solve();
  }
  return 0;
}
0