結果

問題 No.832 麻雀修行中
ユーザー 沙耶花沙耶花
提出日時 2020-12-09 21:58:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 2,322 ms
コンパイル使用メモリ 205,252 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 08:20:59
合計ジャッジ時間 4,216 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 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 2 ms
4,348 KB
testcase_15 AC 2 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 2 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 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 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0