結果

問題 No.832 麻雀修行中
ユーザー ttttan2ttttan2
提出日時 2019-05-24 22:58:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,138 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 169,420 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 14:05:45
合計ジャッジ時間 3,390 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
bool dfs(vector<ll> v,ll c){
    if(v.size()==0)return true;
    ll cnt[10];fill(cnt,cnt+10,0);
    rep(i,0,v.size())cnt[v[i]]++;
    ll u=v[0];
    vector<ll> w=v;
    if(cnt[u]>=3){
        rep(i,0,3){
            rep(j,0,w.size()){
                if(w[j]==u){
                    w.erase(w.begin()+j);
                    break;
                }
            }
        }
        bool jud=dfs(w,c);
        if(jud)return true;
    }
    w=v;
    if(cnt[u]>=2&&c==0){
        rep(i,0,2){
            rep(j,0,w.size()){
                if(w[j]==u){
                    w.erase(w.begin()+j);
                    break;
                }
            }
        }
        bool jud=dfs(w,c+1);
        if(jud)return true;
    }
    w=v;
    if(cnt[u]>=1&&u<=7){
        if(cnt[u+1]>=1&&cnt[u+2]>=1){
            rep(i,u,u+3){
                rep(j,0,w.size()){
                    if(w[j]==i){
                        w.erase(w.begin()+j);
                        break;
                    }
                }
            }
            bool jud=dfs(w,c);
            if(jud)return true;
        }
    }
    return false;
}
int main(){
    vector<ll> v;
    string s;cin>>s;
    rep(i,0,13)v.push_back(s[i]-'0');
    ll cn[10];
    fill(cn,cn+10,0);
    rep(i,0,13)cn[v[i]]++;
    rep(i,1,10){
        if(cn[i]==4)continue;
        ll sum=0;
        rep(j,1,10){
            if(cn[j]==2)sum++;
        }
        if(sum==6&&cn[i]==1){
            cout<<i<<endl;
            continue;
        }
        vector<ll> w=v;
        w.push_back(i);
        sort(w.begin(),w.end());
        bool jud=dfs(w,0);
        if(jud)cout<<i<<endl;
    }
}
0