結果

問題 No.832 麻雀修行中
ユーザー firiexpfiriexp
提出日時 2019-05-24 22:35:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,706 bytes
コンパイル時間 1,247 ms
コンパイル使用メモリ 113,212 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 02:52:29
合計ジャッジ時間 3,291 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
6,812 KB
testcase_01 AC 33 ms
6,944 KB
testcase_02 AC 22 ms
6,940 KB
testcase_03 AC 33 ms
6,940 KB
testcase_04 AC 39 ms
6,944 KB
testcase_05 AC 36 ms
6,940 KB
testcase_06 AC 36 ms
6,944 KB
testcase_07 AC 34 ms
6,940 KB
testcase_08 AC 41 ms
6,944 KB
testcase_09 AC 38 ms
6,944 KB
testcase_10 AC 29 ms
6,940 KB
testcase_11 AC 34 ms
6,940 KB
testcase_12 AC 42 ms
6,944 KB
testcase_13 AC 38 ms
6,944 KB
testcase_14 AC 40 ms
6,940 KB
testcase_15 AC 39 ms
6,944 KB
testcase_16 AC 39 ms
6,940 KB
testcase_17 AC 35 ms
6,944 KB
testcase_18 AC 35 ms
6,940 KB
testcase_19 AC 41 ms
6,940 KB
testcase_20 AC 18 ms
6,944 KB
testcase_21 AC 38 ms
6,940 KB
testcase_22 AC 36 ms
6,944 KB
testcase_23 AC 40 ms
6,944 KB
testcase_24 AC 31 ms
6,944 KB
testcase_25 AC 33 ms
6,944 KB
testcase_26 AC 36 ms
6,944 KB
testcase_27 AC 20 ms
6,944 KB
testcase_28 AC 34 ms
6,940 KB
testcase_29 AC 19 ms
6,940 KB
testcase_30 AC 32 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <limits>


static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

bool solve(string s){
    map<int, int> m;
    for (auto &&i : s) {
        m[i]++;
    }
    int a = 0;
    for (auto &&j : m) {
        if(j.second == 2) a++;
    }
    if(a == 7) return true;
    sort(s.begin(),s.end());
    vector<string> v, u;
    for (int i = 1; i <= 9; ++i) {
        v.emplace_back(3, (char)(i+'0'));
        u.emplace_back(2, (char)(i+'0'));
    }
    for (int i = 1; i < 8; ++i) {
        string t;
        for (int j = 0; j < 3; ++j) {
            t += (char)(i+j+'0');
        }
        v.emplace_back(t);
    }
    int n = v.size();

    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            for (int k = j; k < n; ++k) {
                for (int l = k; l < n; ++l) {
                    for (int o = 0; o < 9; ++o) {
                        string t = v[i]+v[j]+v[k]+v[l]+u[o];
                        sort(t.begin(),t.end());
                        if(s == t) return true;
                    }
                }
            }
        }
    }
    return false;
}

int main() {
    string s;
    cin >> s;
    map<int, int> cnt;
    for (auto &&i : s) {
        cnt[i-'0']++;
    }
    for (int i = 1; i <= 9; ++i) {
        if(cnt[i] < 4){
            string t = s;
            t += char(i + '0');
            if(solve(t)) cout << i << "\n";
        }
    }
    return 0;
}
0