結果

問題 No.832 麻雀修行中
ユーザー kotamanegikotamanegi
提出日時 2019-05-24 22:13:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,122 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 103,356 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 12:46:48
合計ジャッジ時間 1,748 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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;
}
0