結果

問題 No.361 門松ゲーム2
ユーザー 0x19f0x19f
提出日時 2017-12-10 23:12:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 463 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 1,551 ms
コンパイル使用メモリ 150,176 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 10:00:34
合計ジャッジ時間 3,204 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 159 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 48 ms
4,380 KB
testcase_17 AC 16 ms
4,380 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 10 ms
4,376 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 52 ms
4,380 KB
testcase_22 AC 463 ms
4,380 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 6 ms
4,380 KB
testcase_26 AC 20 ms
4,380 KB
testcase_27 AC 25 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll L, D;
ll memo[1000];

bool ok(ll l1, ll l2, ll l3, ll l) {
  if(l1 + l2 + l3 == l)
    if(l1 != l2 && l2 != l3 && l3 != l1)
      if(l1 > 0 && l2 > 0 && l3 > 0)
        if(max({ l1, l2, l3 }) - min({ l1, l2, l3 }) <= D)
         return true;
  return false;
}

ll grundy(ll l) {
  ll &g = memo[l];
  if(g >= 0) return g;
  set<ll> st;
  REP(i, 1, l + 1) REP(j, i + 1, l + 1) {
    ll k = l - i - j;
    if(ok(i, j, k, l)) st.insert(grundy(i) ^ grundy(j) ^ grundy(k));
  }
  g = 0;
  while(st.count(g)) g++;
  return g;
}

int main(void) {
  cin >> L >> D;

  REP(i, 0, 1000) memo[i] = -1;
  cout << (grundy(L) != 0 ? "kado" : "matsu") << endl;
}
0