結果

問題 No.233 めぐるはめぐる (3)
ユーザー koyoprokoyopro
提出日時 2015-10-18 00:20:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 203 ms / 1,000 ms
コード長 977 bytes
コンパイル時間 1,581 ms
コンパイル使用メモリ 157,524 KB
実行使用メモリ 13,752 KB
最終ジャッジ日時 2023-09-28 21:58:15
合計ジャッジ時間 5,612 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
13,056 KB
testcase_01 AC 86 ms
9,644 KB
testcase_02 AC 37 ms
6,528 KB
testcase_03 AC 98 ms
10,300 KB
testcase_04 AC 203 ms
13,468 KB
testcase_05 AC 181 ms
13,488 KB
testcase_06 AC 162 ms
13,540 KB
testcase_07 AC 202 ms
13,752 KB
testcase_08 AC 195 ms
13,472 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 84 ms
9,772 KB
testcase_13 AC 148 ms
13,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
#define ALL(a) (a).begin(),(a).end()
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()

int N,T;
map<string, bool> has;
signed main()
{
    cin >> N;
    string s;
    REP(i,N) {
        cin >> s;
        has[s] = true;
    }
    string vowels = "iaaeuu";
    string consonants = "tnbmgr";
    sort(ALL(vowels));
    sort(ALL(consonants));
    string t = "";
    bool ok = false;
    do {
        do {
            t = "";
            REP(i,6) {
                char c = consonants[i];
                if (c != 't') t += c;
                t += vowels[i];
            }
            if (!has[t]) {
                ok = true;
                break;
            }
        }while(next_permutation(ALL(consonants)));
        if (ok) break;
    }while(next_permutation(ALL(vowels)));

    if (ok) {
        cout << t << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}
0