結果

問題 No.832 麻雀修行中
ユーザー mamekin
提出日時 2019-05-26 10:55:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,857 bytes
コンパイル時間 1,127 ms
コンパイル使用メモリ 117,236 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-17 15:11:16
合計ジャッジ時間 2,140 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;
bool solve(const vector<int>& cnt, int step)
{
if(step == 5)
return true;
if(step == 0){
for(int i=0; i<9; ++i){
if(cnt[i] < 2)
continue;
vector<int> cnt2 = cnt;
cnt2[i] -= 2;
if(solve(cnt2, 1))
return true;
}
bool chitoi = true;
for(int i=0; i<9; ++i){
if(cnt[i] != 0 && cnt[i] != 2)
chitoi = false;
}
if(chitoi)
return true;
}
else{
int i = 0;
while(cnt[i] == 0)
++ i;
if(cnt[i] >= 3){
vector<int> cnt2 = cnt;
cnt2[i] -= 3;
if(solve(cnt2, step + 1))
return true;
}
if(i < 7 && cnt[i+1] > 0 && cnt[i+2] > 0){
vector<int> cnt2 = cnt;
-- cnt2[i];
-- cnt2[i+1];
-- cnt2[i+2];
if(solve(cnt2, step + 1))
return true;
}
}
return false;
}
int main()
{
vector<int> cnt(9, 0);
for(int i=0; i<13; ++i){
char c;
cin >> c;
++ cnt[c-'1'];
}
for(int i=0; i<9; ++i){
if(cnt[i] == 4)
continue;
++ cnt[i];
if(solve(cnt, 0))
cout << (i + 1) << endl;
-- cnt[i];
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0