結果
問題 |
No.832 麻雀修行中
|
ユーザー |
![]() |
提出日時 | 2022-04-10 22:36:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,399 bytes |
コンパイル時間 | 1,929 ms |
コンパイル使用メモリ | 198,572 KB |
最終ジャッジ日時 | 2025-01-28 17:22:52 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 5 |
other | AC * 5 WA * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; bool mentsu(vector<int> &hand, int remaining) { if (remaining == 0) return true; for (int i = 0; i < 9; i++) { if (hand.at(i) < 3) continue; hand.at(i) -= 3; if (mentsu(hand, remaining - 1)) return true; hand.at(i) += 3; } for (int i = 0; i < 7; i++) { if (hand.at(i) == 0 || hand.at(i + 1) == 0 || hand.at(i + 2) == 0) continue; hand.at(i)--; hand.at(i + 1)--; hand.at(i + 2)--; if (mentsu(hand, remaining - 1)) return true; hand.at(i)++; hand.at(i + 1)++; hand.at(i + 2)++; } return false; } bool isagari(vector<int> &hand) { bool seven_pairs = true; for (int i = 0; i < 9; i++) { if (hand.at(i) != 0 && hand.at(i) != 2) { seven_pairs = false; break; } } if (seven_pairs) return true; for (int i = 0; i < 9; i++) { if (hand.at(i) < 2) continue; hand.at(i) -= 2; if (mentsu(hand, 4)) return true; hand.at(i) += 2; } return false; } int main() { string s; cin >> s; sort(s.begin(), s.end()); vector<int> hand(9); for (int i = 0; i < 13; i++) hand.at(s.at(i) - '1')++; for (int i = 0; i < 9; i++) { if (hand.at(i) == 4) continue; hand.at(i)++; if (isagari(hand)) cout << i + 1 << endl; hand.at(i)--; } }