結果

問題 No.832 麻雀修行中
ユーザー kk
提出日時 2021-02-16 18:13:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 1,353 bytes
コンパイル時間 2,713 ms
コンパイル使用メモリ 220,696 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2023-10-11 07:41:34
合計ジャッジ時間 11,553 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 199 ms
5,968 KB
testcase_01 AC 200 ms
5,996 KB
testcase_02 AC 201 ms
5,984 KB
testcase_03 AC 200 ms
6,076 KB
testcase_04 AC 200 ms
5,844 KB
testcase_05 AC 200 ms
5,848 KB
testcase_06 AC 201 ms
6,052 KB
testcase_07 AC 200 ms
5,932 KB
testcase_08 AC 200 ms
6,144 KB
testcase_09 AC 200 ms
5,860 KB
testcase_10 AC 203 ms
5,844 KB
testcase_11 AC 200 ms
5,880 KB
testcase_12 AC 199 ms
5,860 KB
testcase_13 AC 199 ms
5,868 KB
testcase_14 AC 199 ms
5,968 KB
testcase_15 AC 201 ms
5,860 KB
testcase_16 AC 199 ms
5,856 KB
testcase_17 AC 199 ms
5,864 KB
testcase_18 AC 198 ms
5,844 KB
testcase_19 AC 203 ms
5,880 KB
testcase_20 AC 199 ms
5,904 KB
testcase_21 AC 200 ms
5,864 KB
testcase_22 AC 199 ms
5,912 KB
testcase_23 AC 201 ms
5,928 KB
testcase_24 AC 200 ms
6,040 KB
testcase_25 AC 200 ms
5,852 KB
testcase_26 AC 201 ms
5,912 KB
testcase_27 AC 200 ms
5,968 KB
testcase_28 AC 202 ms
5,908 KB
testcase_29 AC 200 ms
5,864 KB
testcase_30 AC 200 ms
5,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)


set<string> build() {
  set<string> agari;
  vector<string> v;

  // 刻子
  for (char c = '1'; c <= '9'; c++)
    v.emplace_back(string(3, c));

  // 順子
  for (char c = '1'; c + 2 <= '9'; c++)
    v.emplace_back(string(1, c) + string(1, c+1) + string(1, c+2));

  for (char c = '1'; c <= '9'; c++) { // 雀頭
    for (int i = 0; i < v.size(); i++)
      for (int j = 0; j < v.size(); j++)
        for (int k = 0; k < v.size(); k++)
          for (int l = 0; l < v.size(); l++) {
            string s = string(2, c) + v[i] + v[j] + v[k] + v[l];
            sort(s.begin(), s.end());
            agari.insert(s);
          }
  }
  return agari;
}

bool check(string s, const set<string> &agari) {
  map<char, int> hist;
  for (char c: s)
    hist[c]++;

  // 牌数のチェック
  for (auto &[k, v]: hist)
    if (v > 4)
      return false;

  // 七対子
  bool pr = true;;
  for (auto &[k, v]: hist)
    pr &= v == 2;
  if (pr)
    return true;

  // その他
  sort(s.begin(), s.end());
  return agari.count(s);
}

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

  string s;
  cin >> s;

  set<string> agari = build();
  for (char c = '1'; c <= '9'; c++) {
    if (check(s + c, agari))
      cout << c << endl;
  }
  
  return 0;
}
0