結果

問題 No.361 門松ゲーム2
コンテスト
ユーザー siman
提出日時 2022-11-17 13:38:28
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.89.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 732 ms / 2,000 ms
コード長 1,022 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,974 ms
コンパイル使用メモリ 150,400 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-07 06:29:02
合計ジャッジ時間 8,274 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:19:14: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   19 |   int is_win[L + 1];
      |              ^~~~~
main.cpp:19:14: note: read of non-const variable 'L' is not allowed in a constant expression
main.cpp:17:7: note: declared here
   17 |   int L, D;
      |       ^
1 warning generated.

ソースコード

diff #
raw source code

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int L, D;
  cin >> L >> D;
  int is_win[L + 1];
  memset(is_win, 0, sizeof(is_win));

  for (int l = 1; l <= L; ++l) {
    set<int> S;

    for (int a = 1; a <= l - 2; ++a) {
      for (int b = 1; b <= l - a; ++b) {
        int c = l - a - b;
        if (a + b + c != l) continue;
        if (a == b) continue;
        if (a == c) continue;
        if (b == c) continue;
        if (c <= 0) continue;
        int max_l = max(a, max(b, c));
        int min_l = min(a, min(b, c));
        if (max_l - min_l > D) continue;

        S.insert(is_win[a] ^ is_win[b] ^ is_win[c]);
      }
    }

    while (S.count(is_win[l])) {
      is_win[l]++;
    }
  }

  if (is_win[L] == 0) {
    cout << "matsu" << endl;
  } else {
    cout << "kado" << endl;
  }

  return 0;
}
0