結果
問題 | No.832 麻雀修行中 |
ユーザー |
|
提出日時 | 2022-10-22 03:11:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,575 bytes |
コンパイル時間 | 2,191 ms |
コンパイル使用メモリ | 196,608 KB |
最終ジャッジ日時 | 2025-02-08 10:54:36 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; int main(){ cin.tie(0); ios::sync_with_stdio(0); string s; cin >> s; vector<int> cnt(10, 0); for(char c : s) cnt[c - '0']++; auto f = [](vector<int> cnt) { // 1 for(int A = 1; A <= 9; A++) { if(cnt[A] >= 2) { vector<int> a = cnt; a[A] -= 2; int k = 0; for(int B : {1, 9, 2, 8, 3, 7, 4, 6, 5}) { if(a[B] >= 3) a[B] -= 3, k++; if(a[B] > 0) { if(a[B + 1] >= a[B] && a[B + 2] >= a[B]) { a[B + 1] -= a[B]; a[B + 2] -= a[B]; k += a[B]; a[B] = 0; } else if(a[B - 2] >= a[B] && a[B - 1] >= a[B]) { a[B - 2] -= a[B]; a[B - 1] -= a[B]; k += a[B]; a[B] = 0; } else break; } } if(k == 4) return true; } } // 2 int k = 0; for(int i = 1; i <= 9; i++) if(cnt[i] == 2) k++; if(k == 7) return true; return false; }; for(int x = 1; x <= 9; x++) { if(cnt[x] < 4) { cnt[x]++; if(f(cnt)) cout << x << "\n"; cnt[x]--; } } }