結果

問題 No.361 門松ゲーム2
コンテスト
ユーザー siman
提出日時 2022-11-17 13:25:09
言語 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
結果
WA  
実行時間 -
コード長 1,170 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,726 ms
コンパイル使用メモリ 151,168 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-07 06:15:17
合計ジャッジ時間 5,938 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:19:15: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   19 |   bool is_win[L + 1];
      |               ^~~~~
main.cpp:19:15: 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;
  bool is_win[L + 1];
  memset(is_win, false, sizeof(is_win));

  for (int l = 3; l <= L; ++l) {
    bool ok = false;

    for (int a = 1; a <= l; ++a) {
      for (int b = 1; b <= l; ++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;

        int win_cnt = 0;
        if (is_win[a]) ++win_cnt;
        if (is_win[b]) ++win_cnt;
        if (is_win[c]) ++win_cnt;

        if (win_cnt % 2 == 0) {
          ok = true;
        }
      }
    }

    // fprintf(stderr, "l: %d, res: %d\n", l, ok);
    is_win[l] = ok;
  }

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

  return 0;
}
0