結果

問題 No.233 めぐるはめぐる (3)
ユーザー MisterMister
提出日時 2020-09-04 17:29:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 1,519 bytes
コンパイル時間 938 ms
コンパイル使用メモリ 90,620 KB
実行使用メモリ 17,320 KB
最終ジャッジ日時 2023-08-17 11:32:07
合計ジャッジ時間 4,869 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
16,744 KB
testcase_01 AC 58 ms
13,552 KB
testcase_02 AC 31 ms
10,128 KB
testcase_03 AC 63 ms
14,092 KB
testcase_04 AC 132 ms
17,240 KB
testcase_05 AC 110 ms
17,308 KB
testcase_06 AC 101 ms
17,288 KB
testcase_07 AC 131 ms
17,252 KB
testcase_08 AC 131 ms
17,320 KB
testcase_09 AC 11 ms
7,816 KB
testcase_10 AC 11 ms
7,724 KB
testcase_11 AC 11 ms
7,784 KB
testcase_12 AC 58 ms
13,572 KB
testcase_13 AC 91 ms
16,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

void solve() {
    std::vector<std::string> vow, con;
    {
        std::string s = "aaeiuu";
        do {
            vow.push_back(s);
        } while (std::next_permutation(s.begin(), s.end()));

        s = "bgmnr";
        do {
            con.push_back(s);
        } while (std::next_permutation(s.begin(), s.end()));
    }

    std::vector<std::string> ss;
    for (int b = 0; b < (1 << 11); ++b) {
        if (__builtin_popcount(b) != 5 ||
            ((b >> 10) & 1) ||
            (b & (b >> 1))) continue;

        for (const auto& s : vow) {
            for (const auto& t : con) {
                std::string r;
                int si = 0, ti = 0;

                for (int i = 0; i < 11; ++i) {
                    if ((b >> i) & 1) {
                        r.push_back(t[ti++]);
                    } else {
                        r.push_back(s[si++]);
                    }
                }

                ss.push_back(r);
            }
        }
    }

    std::set<std::string> ts;
    {
        int n;
        std::cin >> n;
        while (n--) {
            std::string t;
            std::cin >> t;
            ts.insert(t);
        }
    }

    for (const auto& s : ss) {
        if (ts.count(s)) continue;
        std::cout << s << "\n";
        return;
    }

    std::cout << "NO\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0