結果

問題 No.832 麻雀修行中
ユーザー face4face4
提出日時 2019-05-24 21:58:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,369 bytes
コンパイル時間 618 ms
コンパイル使用メモリ 71,132 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 12:32:26
合計ジャッジ時間 2,035 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

int main(){
    string s;
    cin >> s;
    vector<int> cnt(9,0);
    for(char c : s) cnt[c-'1']++;
    for(int i = 0; i < 9; i++){
        if(cnt[i] == 4) continue;
        cnt[i]++;
        
        bool toitu = true, temp = false;
        for(int j = 0; j < 10; j++) toitu &= (cnt[j]==2||cnt[j]==0);

        for(int j = 0; j < 1<<9; j++){
            vector<int> cp = cnt;
            bool valid = true;
            for(int k = 0; k < 9; k++){
                if((j>>k)&1){
                    if(cp[k] < 3)  valid = false;
                    cp[k] -= 3;
                }
            }
            if(!valid)  continue;
            for(int janto = 0; janto < 9; janto++){
                if(cp[janto] < 2)   continue;
                vector<int> ncp= cp;
                ncp[janto] -= 2;
                bool ok = true;
                for(int k = 0; k < 7; k++){
                    if(ncp[k] == 0)  continue;
                    if(ncp[k+1]==0||ncp[k+2]==0){
                        ok = false;
                        break;
                    }
                    ncp[k]--, ncp[k+1]--, ncp[k+2]--;
                    k--;
                }
                if(ok)  temp = true;
            }
        }
        
        cnt[i]--;
        if(toitu || temp)   cout << i+1 << endl;
    }
    return 0;
}
0