結果
| 問題 |
No.832 麻雀修行中
|
| コンテスト | |
| ユーザー |
ttttan2
|
| 提出日時 | 2019-05-24 22:58:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,138 bytes |
| コンパイル時間 | 1,461 ms |
| コンパイル使用メモリ | 168,256 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-17 11:54:16 |
| 合計ジャッジ時間 | 2,452 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 25 |
ソースコード
#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;
}
}
ttttan2