結果

問題 No.361 門松ゲーム2
ユーザー k
提出日時 2021-03-14 03:13:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 198,312 KB
最終ジャッジ日時 2025-01-19 16:15:46
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int l, d;
  cin >> l >> d;

  vector<int> grundy(l+1);
  for (int k = 1; k <= l; k++) {
    set<int> mex;
    for (int x = 0; x < k; x++) {
      for (int y = 0; y < x; y++) {
        int z = k - x - y;
        if (0 < z && z < y) {  // x > y > z > 0
          if (x - z <= d) {
            mex.insert(grundy[x] ^ grundy[y] ^ grundy[z]);
          }
        }
      }
    }
    while (mex.count(grundy[k]))
      ++grundy[k];
  }

  
  if (grundy[l])
    cout << "kado" << endl;
  else
    cout << "matsu" << endl;

  return 0;
}
0