結果

問題 No.233 めぐるはめぐる (3)
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-01-14 17:49:40
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 188 ms / 1,000 ms
コード長 1,970 bytes
コンパイル時間 1,491 ms
コンパイル使用メモリ 174,516 KB
実行使用メモリ 17,384 KB
最終ジャッジ日時 2024-09-19 19:03:27
合計ジャッジ時間 4,751 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

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