結果

問題 No.832 麻雀修行中
ユーザー cotton_fn_cotton_fn_
提出日時 2019-05-24 23:21:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,239 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 118,784 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 14:49:52
合計ジャッジ時間 4,137 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string add(i32 k, string s) {
  if (k < 9) {
    for (i64 i = 0; i < 3; ++i) s.push_back(k + '1');
  } else {
    for (i64 i = 0; i < 3; ++i) s.push_back(k - 9 + '1' + i);
  }
  return s;
}

bool valid(const string& s) {
  i32 cnt[9];
  fill(begin(cnt), end(cnt), 0);
  for (char c : s) cnt[c - '1']++;
  for (i32 i = 0; i < 9; ++i) if (cnt[i] > 4) return false;
  return true;
}

string s;
bool ok[9];
int main() {
  cin >> s;
  sort(begin(s), end(s));
  for (i64 b = 0; b < 9; ++b) {
    string y = s;
    y.push_back(b + '1');
    sort(begin(y), end(y));
    if (!valid(y)) continue;
    for (i64 i = 0; i < 16; ++i) {
      string t = add(i, string());
      for (i64 j = i; j < 16; ++j) {
        string u = add(j, t);
        for (i64 k = j; k < 16; ++k) {
          string v = add(k, u);
          for (i64 l = k; l < 16; ++l) {
            string w = add(l, v);
            for (i64 a = 0; a < 9; ++a) {
              string x = w;
              x.push_back(a + '1');
              x.push_back(a + '1');
              sort(begin(x), end(x));
              if (valid(x) && x == y) ok[b] = true;
            }
          }
        }
      }
    }
    bool f = true;
    for (i64 i = 0; i < 7; ++i) {
      if (y[2 * i] != y[2 * i + 1]) f = false;
    }
    if (f) ok[b] = true;
  }

  for (i32 i = 0; i < 9; ++i) if (ok[i]) cout << char(i + '1') << '\n';
  return 0;
}
0