結果
| 問題 |
No.832 麻雀修行中
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2019-05-24 21:39:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 280 ms / 2,000 ms |
| コード長 | 1,417 bytes |
| コンパイル時間 | 2,283 ms |
| コンパイル使用メモリ | 187,780 KB |
| 実行使用メモリ | 37,920 KB |
| 最終ジャッジ日時 | 2024-09-17 10:30:43 |
| 合計ジャッジ時間 | 12,103 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
int main() {
cin.tie(nullptr); ios::sync_with_stdio(false);
V<string> t;
for (int i = 0; i < 9; ++i) {
t.push_back(string(3, '1' + i));
if (i < 7) {
string x;
x += '1' + i;
x += '1' + i + 1;
x += '1' + i + 2;
t.push_back(x);
}
}
V<string> s;
for (int i = 0; i < 1 << 16; ++i) {
for (int j = 0; j < 9; ++j) {
string x(2, '1' + j);
x += t[i & 15];
x += t[i >> 4 & 15];
x += t[i >> 8 & 15];
x += t[i >> 12 & 15];
sort(begin(x), end(x));
s.push_back(x);
}
}
V<> p{0, 0, 1, 1, 1, 1, 1, 1, 1};
do {
string x;
for (int i = 0; i < 9; ++i) if (p[i]) {
x += string(2, '1' + i);
}
sort(begin(x), end(x));
s.push_back(x);
} while (next_permutation(begin(p), end(p)));
for (auto&& e : s) {
bool ok = true;
for (int i = 0; i < 9; ++i) if (count(begin(e), end(e), '1' + i) > 4) {
ok = false;
break;
}
if (!ok) e = "";
}
sort(begin(s), end(s));
s.erase(unique(begin(s), end(s)), end(s));
string str; cin >> str;
for (int i = 0; i < 9; ++i) {
auto x = str;
x += '1' + i;
sort(begin(x), end(x));
if (!binary_search(begin(s), end(s), x)) continue;
cout << i + 1 << '\n';
}
}
risujiroh