結果
| 問題 |
No.832 麻雀修行中
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2020-12-09 21:58:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 954 bytes |
| コンパイル時間 | 2,181 ms |
| コンパイル使用メモリ | 198,164 KB |
| 最終ジャッジ日時 | 2025-01-16 20:59:18 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 25 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 10000000
bool check(vector<int> cnt,int last = 0){
for(int i=last;i<9;i++){
if(cnt[i]>=3){
cnt[i]-=3;
if(check(cnt))return true;
cnt[i]+=3;
}
if(i<7&&cnt[i]>0&&cnt[i+1]>0&&cnt[i+2]>0){
rep(j,3){
cnt[i+j]--;
}
if(check(cnt))return true;
rep(j,3){
cnt[i+j]++;
}
}
}
bool f = false;
rep(i,9){
if(cnt[i]==2){
if(f)return false;
f=true;
}
else if(cnt[i]!=0)return false;
}
return f;
}
bool check(string S){
vector<int> cnt(9,0);
rep(i,S.size()){
cnt[S[i]-'1']++;
}
rep(i,9){
if(cnt[i]>4)return false;
}
bool f = true;
rep(i,9){
if(cnt[i]!=0&&cnt[i]!=2)f=false;
}
if(f)return true;
return check(cnt);
}
int main(){
string S;
cin>>S;
for(int i=0;i<9;i++){
S += '1'+i;
if(check(S))cout<<S.back()<<endl;
S.pop_back();
}
return 0;
}
沙耶花