結果

問題 No.233 めぐるはめぐる (3)
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-01-14 17:49:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 216 ms / 1,000 ms
コード長 1,970 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 174,588 KB
実行使用メモリ 17,404 KB
最終ジャッジ日時 2023-10-19 23:05:50
合計ジャッジ時間 5,335 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
16,876 KB
testcase_01 AC 79 ms
11,928 KB
testcase_02 AC 35 ms
7,704 KB
testcase_03 AC 87 ms
12,984 KB
testcase_04 AC 216 ms
17,404 KB
testcase_05 AC 172 ms
17,404 KB
testcase_06 AC 173 ms
17,404 KB
testcase_07 AC 212 ms
17,404 KB
testcase_08 AC 212 ms
17,404 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 77 ms
12,192 KB
testcase_13 AC 139 ms
17,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }

    int N;
    vector<string> ss;
    void input() {
        cin >> N;
        ss.clear(); ss.resize(N);
        for (int i = 0; i < N; i++) cin >> ss[i];
    }

    void solve() {
        set<string> M;
        for (int i = 0; i < N; i++) M.insert(ss[i]);
        string vs = "aaeiuu";
        string cs = "bgmnr";
        do {
            do {
                for (int p = 0; p < 6; p++) {
                    string s = "                 ";
                    for (int i = 0; i < p; i++) {
                        s[i * 2] = cs[i];
                    }
                    for (int i = p + 1; i < 6; i++) {
                        s[i * 2] = cs[i - 1];
                    }
                    for (int i = 0; i <= 5; i++) {
                        s[i * 2 + 1] = vs[i];
                    }
                    string t;
                    for (int i = 0; i < s.size(); i++) {
                        char c = s[i];
                        if (c == ' ') continue;
                        t.push_back(c);
                    }
                    string x = t;
                    string y = "inabameguru";
                    sort(x.begin(), x.end());
                    sort(y.begin(), y.end());
                    assert(x == y);
                    if (not M.count(t)) {
                        cout << t << endl;
                        return;
                    }
                }
            } while (next_permutation(cs.begin(), cs.end()));
        } while (next_permutation(vs.begin(), vs.end()));
        cout << "NO" << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

0