結果

問題 No.832 麻雀修行中
ユーザー le_panda_noirle_panda_noir
提出日時 2020-07-23 21:48:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,272 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 70,880 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-06 01:22:09
合計ジャッジ時間 2,063 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,500 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,500 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

bool is_chitoi(int count[9]) {
  rep(i, 9)
    if (count[i] != 0 && count[i] != 2)
      return false;
  return true;
}
bool is_tenpai(int count[9], bool head = false, int mentsu = 0) {
  if (head && mentsu == 4)
    return true;
  if (!head && mentsu == 0 && is_chitoi(count))
    return true;
  bool ok = false;
  rep(i, 9) {
    if (count[i] >= 2 && !head) {
      count[i] -= 2;
      if (is_tenpai(count, true, mentsu))
        ok = true;
      count[i] += 2;
    }
    if (count[i] >= 3) {
      count[i] -= 3;
      if (is_tenpai(count, head, mentsu+1))
        ok = true;
      count[i] += 3;
    }
    if (i+2 < 9 && count[i] > 0 && count[i+1] > 0 && count[i+2] > 0) {
      --count[i]; --count[i+1]; --count[i+2];
      if (is_tenpai(count, head, mentsu+1))
        ok = true;
      ++count[i]; ++count[i+1]; ++count[i+2];
    }
    if (ok)
      return true;
  }
  return false;
}
int main() {
  string S; cin >> S;

  int count[9];
  rep(i, 9) count[i] = 0;
  rep(i, 13) {
    ++count[S[i] - '0' - 1];
  }

  rep(i, 9) {
    if (count[i] == 4)
      continue;
    ++count[i];
    if (is_tenpai(count)) {
      cout << i+1 << endl;
    }
    --count[i];
  }

  return 0;
}
0