結果
問題 | No.832 麻雀修行中 |
ユーザー |
![]() |
提出日時 | 2019-05-24 23:01:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,061 bytes |
コンパイル時間 | 673 ms |
コンパイル使用メモリ | 85,572 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-17 11:57:52 |
合計ジャッジ時間 | 1,522 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 25 |
ソースコード
#include <iostream>#include <cstring>#include <vector>#include <set>#include <list>#include <map>#include <deque>#include <unordered_map>#include <algorithm>#include <utility>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef vector<ll> vll;#define for1(i,n) for (ll i=0;i<(n);i++)#define for2(i,m,n) for (ll i=(m);i<(n);i++)#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))#define DEBUG 0template <class T>void dumplist(T list){for (auto item : list) {cout << item << " ";}cout << endl;}bool check1(vll& hand){ll count = 0;ll max1 = 0;for2(i,1,10) {count += hand[i];max1 = max(max1, hand[i]);}if (count == 2) {if (max1 == 2) {return true;} else {return false;}}bool ret;for2(i,1,10) {if (hand[i] >= 3) {hand[i] -= 3;ret = check1(hand);hand[i] += 3;if (ret) {return true;}}}for2(i,1,8) {if (hand[i] >= 1 && hand[i+1] >= 1 && hand[i+2] >= 1) {hand[i] -= 1;hand[i+1] -= 1;hand[i+2] -= 1;ret = check1(hand);hand[i] += 1;hand[i+1] += 1;hand[i+2] += 1;if (ret) {return true;}}}return false;}bool check2(vll& hand){ll ok = 0;for2(i,1,10) {if (hand[i] == 2) {++ok;}}if (ok == 7) {return true;}return false;}void solve(){string S;vll hand(10,0);cin >> S;for (char c : S) {hand[c - '0'] += 1;}for2(i,1,10) {//dumplist(hand);if (hand[i] <= 3) {hand[i] += 1;if (check1(hand) || check2(hand)) {cout << i << endl;}hand[i] -= 1;}}}int main(){do {solve();} while (DEBUG);}