結果
| 問題 |
No.832 麻雀修行中
|
| コンテスト | |
| ユーザー |
cotton_fn_
|
| 提出日時 | 2019-05-24 23:21:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,239 bytes |
| コンパイル時間 | 1,285 ms |
| コンパイル使用メモリ | 115,416 KB |
| 最終ジャッジ日時 | 2025-01-07 04:02:30 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 WA * 1 |
| other | AC * 24 WA * 1 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>
using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x)
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs
string add(i32 k, string s) {
if (k < 9) {
for (i64 i = 0; i < 3; ++i) s.push_back(k + '1');
} else {
for (i64 i = 0; i < 3; ++i) s.push_back(k - 9 + '1' + i);
}
return s;
}
bool valid(const string& s) {
i32 cnt[9];
fill(begin(cnt), end(cnt), 0);
for (char c : s) cnt[c - '1']++;
for (i32 i = 0; i < 9; ++i) if (cnt[i] > 4) return false;
return true;
}
string s;
bool ok[9];
int main() {
cin >> s;
sort(begin(s), end(s));
for (i64 b = 0; b < 9; ++b) {
string y = s;
y.push_back(b + '1');
sort(begin(y), end(y));
if (!valid(y)) continue;
for (i64 i = 0; i < 16; ++i) {
string t = add(i, string());
for (i64 j = i; j < 16; ++j) {
string u = add(j, t);
for (i64 k = j; k < 16; ++k) {
string v = add(k, u);
for (i64 l = k; l < 16; ++l) {
string w = add(l, v);
for (i64 a = 0; a < 9; ++a) {
string x = w;
x.push_back(a + '1');
x.push_back(a + '1');
sort(begin(x), end(x));
if (valid(x) && x == y) ok[b] = true;
}
}
}
}
}
bool f = true;
for (i64 i = 0; i < 7; ++i) {
if (y[2 * i] != y[2 * i + 1]) f = false;
}
if (f) ok[b] = true;
}
for (i32 i = 0; i < 9; ++i) if (ok[i]) cout << char(i + '1') << '\n';
return 0;
}
cotton_fn_