結果

問題 No.233 めぐるはめぐる (3)
ユーザー MisterMister
提出日時 2020-09-04 17:29:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 1,000 ms
コード長 1,519 bytes
コンパイル時間 1,084 ms
コンパイル使用メモリ 91,352 KB
実行使用メモリ 17,520 KB
最終ジャッジ日時 2024-05-04 18:15:34
合計ジャッジ時間 4,824 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
17,004 KB
testcase_01 AC 52 ms
13,552 KB
testcase_02 AC 30 ms
10,480 KB
testcase_03 AC 60 ms
14,260 KB
testcase_04 AC 121 ms
17,516 KB
testcase_05 AC 105 ms
17,520 KB
testcase_06 AC 95 ms
17,388 KB
testcase_07 AC 120 ms
17,392 KB
testcase_08 AC 124 ms
17,392 KB
testcase_09 AC 11 ms
7,536 KB
testcase_10 AC 10 ms
7,408 KB
testcase_11 AC 11 ms
7,412 KB
testcase_12 AC 52 ms
13,684 KB
testcase_13 AC 85 ms
17,244 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