結果
| 問題 |
No.832 麻雀修行中
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-24 22:04:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 874 bytes |
| コンパイル時間 | 539 ms |
| コンパイル使用メモリ | 67,572 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-17 10:42:20 |
| 合計ジャッジ時間 | 1,486 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 25 |
コンパイルメッセージ
main.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
44 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
using namespace std;
int cnt[14];
bool dfs(int id,int mentu,bool atama)
{
if(id==10)
{
int now[14];
for(int j=1;j<=9;j++)now[j]=cnt[j];
for(int j=1;j<=7;j++)
{
while(now[j]&&now[j+1]&&now[j+2])
{
now[j]--,now[j+1]--,now[j+2]--;
mentu++;
}
}
if(mentu==4&&atama)return true;
else return false;
}
bool flag=false;
if(id==1)
{
int c=0;
for(int j=1;j<=9;j++)c+=cnt[j]==2;
if(c==7)return true;
}
if(cnt[id]>=3)
{
cnt[id]-=3;
flag|=dfs(id+1,mentu+1,atama);
cnt[id]+=3;
}
flag|=dfs(id+1,mentu,atama);
if(!atama&&cnt[id]>=2)
{
cnt[id]-=2;
flag|=dfs(id+1,mentu,true);
cnt[id]+=2;
}
return flag;
}
main()
{
string s;cin>>s;
for(int i=0;i<s.size();i++)cnt[s[i]-'0']++;
for(int i=1;i<=9;i++)
{
if(cnt[i]==4)continue;
cnt[i]++;
if(dfs(1,0,false))cout<<i<<endl;
cnt[i]--;
}
}