結果

問題 No.832 麻雀修行中
ユーザー kotamanegi
提出日時 2019-05-24 22:13:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,122 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 102,400 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-17 10:51:03
合計ジャッジ時間 1,794 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
long long inv(long long now) {
long long ans = 1;
long long te = MAX_MOD - 2LL;
while (te != 0) {
if (te % 2 == 1) {
ans *= now;
ans %= MAX_MOD;
}
te /= 2;
now *= now;
now %= MAX_MOD;
}
return ans;
}
int cnt[20] = {};
int solve(long long step) {
int cnter = 0;
int type = 0;
REP(i, 9) {
cnter += cnt[i + 1];
if (cnt[i + 1] >= 1) {
type++;
}
}
if (cnter == 2&&type == 1) {
return 1;
}
for (int i = step; i < 20; ++i) {
if (i < 9) {
if (cnt[i + 1] >= 3) {
cnt[i + 1] -= 3;
int hoge = solve(i);
cnt[i + 1] += 3;
if (hoge == 1) {
return 1;
}
}
}
else {
//narabi
int tea = i - 9;
if (cnt[tea + 1] >= 1 && cnt[tea + 2] >= 1 && cnt[tea + 3] >= 1) {
cnt[tea + 1]--;
cnt[tea + 2]--;
cnt[tea + 3]--;
int hoge = solve(i);
cnt[tea + 1]++;
cnt[tea + 2]++;
cnt[tea + 3]++;
if (hoge == 1) {
return 1;
}
}
}
}
return 0;
}
int main(){
string s;
cin >> s;
REP(i, s.length()) {
cnt[s[i] - '0']++;
}
for (int i = 1; i < 10; ++i) {
if (cnt[i] == 4) continue;
cnt[i]++;
if (solve(0) == 1) {
cout << i << endl;
}
else {
int hoge = 0;
for (int q = 1; q <= 10; ++q) {
hoge += cnt[q] % 2;
if (cnt[q] == 4) hoge++;
}
if (hoge == 0) {
cout << i << endl;
}
}
cnt[i]--;
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0