結果

問題 No.832 麻雀修行中
ユーザー furafura
提出日時 2020-05-31 00:31:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 2,424 ms
コンパイル使用メモリ 203,156 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-26 10:06:27
合計ジャッジ時間 3,204 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,948 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

bool check3(string s){
	int n=s.length();
	if(n==0) return true;
	rep(i,n) for(int j=i+1;j<n;j++) for(int k=j+1;k<n;k++) {
		if((s[i]==s[j] && s[i]==s[k])
		|| (s[i]+1==s[j] && s[i]+2==s[k])){
			return check3(s.substr(0,i)+s.substr(i+1,j-i-1)+s.substr(j+1,k-j-1)+s.substr(k+1));
		}
	}
	return false;
}

bool check(string s){
	string t[7];
	rep(i,7) t[i]=s.substr(2*i,2);
	bool ok=true;
	rep(i,7){
		if(t[i][0]!=t[i][1]) ok=false;
		rep(j,i) if(t[i]==t[j]) ok=false;
	}
	if(ok) return true;

	rep(i,13) if(s[i]==s[i+1]) {
		string t=s.substr(0,i)+s.substr(i+2);
		if(check3(t)) return true;
	}
	return false;
}

int main(){
	string s; cin>>s;
	for(char c='1';c<='9';c++){
		if(count(s.begin(),s.end(),c)<4){
			string t=s+c;
			sort(t.begin(),t.end());
			if(check(t)) printf("%c\n",c);
		}
	}
	return 0;
}
0