結果

問題 No.233 めぐるはめぐる (3)
コンテスト
ユーザー はむ吉🐹
提出日時 2016-03-02 22:32:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 164 ms / 1,000 ms
コード長 1,260 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 69,324 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-09-24 13:35:38
合計ジャッジ時間 3,769 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdlib>
#include <ios>
#include <iostream>
#include <set>
#include <string>


std::string get_available_name(std::set<std::string>& used_names) {
	std::string consonants("bgmnr");
	std::string vowels("aaeiuu");
	do {
		do {
			std::string candidate_init;
			for (unsigned int i = 0; i < 5; i++) {
				candidate_init.push_back(consonants[i]);
				candidate_init.push_back(vowels[i]);
			}
			auto last_vowel = vowels.back();
			for (unsigned int i = 0; i <= 10; i++) {
				auto cand_init_copy = candidate_init;
				cand_init_copy.insert(cand_init_copy.begin() + i, last_vowel);
				auto used = used_names.find(cand_init_copy);
				if (used == used_names.end()) {
					return cand_init_copy;
				}
			}
		} while (std::next_permutation(vowels.begin(), vowels.end()));
	} while (std::next_permutation(consonants.begin(), consonants.end()));
	std::string result("NO");
	return result;
}


int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	unsigned int n;
	std::cin >> n;
	std::set<std::string> used_names;
	for (unsigned int i = 0; i < n; i++) {
		std::string s;
		std::cin >> s;
		used_names.insert(s);
	}
	auto result = get_available_name(used_names);
	std::cout << result << std::endl;
	
	return EXIT_SUCCESS;
}
0