結果
問題 | No.832 麻雀修行中 |
ユーザー |
![]() |
提出日時 | 2019-05-24 22:24:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,911 bytes |
コンパイル時間 | 2,124 ms |
コンパイル使用メモリ | 117,444 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 10:57:12 |
合計ジャッジ時間 | 2,106 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 25 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:65, from main.cpp:6: In member function 'std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](size_type) [with _Alloc = std::allocator<bool>]', inlined from 'int main()' at main.cpp:44:23: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_bvector.h:1036:23: warning: 'need' may be used uninitialized [-Wmaybe-uninitialized] 1036 | { return begin()[__n]; } | ~~~~~~~^ main.cpp: In function 'int main()': main.cpp:32:9: note: 'need' was declared here 32 | int need; | ^~~~
ソースコード
#include <algorithm>#include <iostream>#include <iomanip>#include <cstring>#include <string>#include <vector>#include <random>#include <bitset>#include <queue>#include <cmath>#include <stack>#include <set>#include <map>typedef long long ll;using namespace std;const ll MOD = 1000000007LL;int main() {cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);string s;cin >> s;map<int, int> mp;for (char c : s) mp[c - '0']++;vector<bool> ans(10, false);// 2 * 7 のチェックint need;int count = 0;bool flag = true;for (auto itr = mp.begin(); itr != mp.end(); itr++) {if (itr->second == 1) {if (count > 0) flag = false;need = itr->first;count++;} else if (itr->second > 2) {flag = false;}}if (flag) ans[need] = true;// 2 3 3 3 3 のチェックfor (int i = 1; i < 10; i++) {// 挿入する数字がiの時if (mp[i] == 4) continue;mp[i]++;bool possible = false;for (int j = 1; j < 10; j++) {// 2のペアがjの時if (mp[j] < 2) continue;mp[j] -= 2;map<int, int> mp2;for (auto itr = mp.begin(); itr != mp.end(); itr++) mp2[itr->first] = itr->second;bool pos = true;for (int k = 1; k < 12; k++) {if (mp2[k] < 0) pos = false;if (mp2[k] >= 3) mp2[k] -= 3;if (mp2[k] > 0) {mp2[k + 1] -= mp2[k];mp2[k + 2] -= mp2[k];}}if (pos) possible = true;mp[j] += 2;}if (possible) ans[i] = true;mp[i]--;}for (int i = 1; i < 10; i++) {if (ans[i]) {cout << i << "\n";}}return 0;}