結果
| 問題 |
No.233 めぐるはめぐる (3)
|
| コンテスト | |
| ユーザー |
ふーらくたる
|
| 提出日時 | 2016-07-10 18:06:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,400 bytes |
| コンパイル時間 | 783 ms |
| コンパイル使用メモリ | 69,244 KB |
| 実行使用メモリ | 9,296 KB |
| 最終ジャッジ日時 | 2024-10-13 10:26:20 |
| 合計ジャッジ時間 | 6,796 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 11 |
ソースコード
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
int N;
vector<string> names;
char vowel[6] = {'i', 'a' ,'a', 'e', 'u', 'u'},
consonant[5] = {'n', 'b', 'm', 'g', 'r'};
bool v_used[6], c_used[5];
string answer;
void DFS(int v_num, int c_num, bool prev_is_consonants, string accum) {
if (answer != "") return;
if (v_num == 6 && c_num == 5) {
if (find(names.begin(), names.end(), accum) == names.end()) {
answer = accum;
}
return;
}
for (int i = 0; i < 6; i++) {
if (!v_used[i]) {
v_used[i] = true;
accum.push_back(vowel[i]);
DFS(v_num + 1, c_num, false, accum);
v_used[i] = false;
accum.pop_back();
}
}
if (prev_is_consonants) return;
for (int i = 0; i < 5; i++) {
if (!c_used[i]) {
c_used[i] = true;
accum.push_back(consonant[i]);
DFS(v_num, c_num + 1, true, accum);
c_used[i] = false;
accum.pop_back();
}
}
}
void Solve() {
answer = "";
DFS(0, 0, false, "");
if (answer == "") cout << "NO" << endl;
else cout << answer << endl;
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
string name;
cin >> name;
names.push_back(name);
}
Solve();
return 0;
}
ふーらくたる