結果
| 問題 |
No.832 麻雀修行中
|
| コンテスト | |
| ユーザー |
le_panda_noir
|
| 提出日時 | 2020-07-23 21:48:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,272 bytes |
| コンパイル時間 | 656 ms |
| コンパイル使用メモリ | 68,088 KB |
| 最終ジャッジ日時 | 2025-01-12 04:32:50 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 25 |
ソースコード
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
bool is_chitoi(int count[9]) {
rep(i, 9)
if (count[i] != 0 && count[i] != 2)
return false;
return true;
}
bool is_tenpai(int count[9], bool head = false, int mentsu = 0) {
if (head && mentsu == 4)
return true;
if (!head && mentsu == 0 && is_chitoi(count))
return true;
bool ok = false;
rep(i, 9) {
if (count[i] >= 2 && !head) {
count[i] -= 2;
if (is_tenpai(count, true, mentsu))
ok = true;
count[i] += 2;
}
if (count[i] >= 3) {
count[i] -= 3;
if (is_tenpai(count, head, mentsu+1))
ok = true;
count[i] += 3;
}
if (i+2 < 9 && count[i] > 0 && count[i+1] > 0 && count[i+2] > 0) {
--count[i]; --count[i+1]; --count[i+2];
if (is_tenpai(count, head, mentsu+1))
ok = true;
++count[i]; ++count[i+1]; ++count[i+2];
}
if (ok)
return true;
}
return false;
}
int main() {
string S; cin >> S;
int count[9];
rep(i, 9) count[i] = 0;
rep(i, 13) {
++count[S[i] - '0' - 1];
}
rep(i, 9) {
if (count[i] == 4)
continue;
++count[i];
if (is_tenpai(count)) {
cout << i+1 << endl;
}
--count[i];
}
return 0;
}
le_panda_noir