結果

問題 No.233 めぐるはめぐる (3)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-03-02 22:32:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 142 ms / 1,000 ms
コード長 1,260 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 70,084 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2023-10-24 19:35:18
合計ジャッジ時間 3,529 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
13,352 KB
testcase_01 AC 47 ms
9,928 KB
testcase_02 AC 22 ms
6,764 KB
testcase_03 AC 53 ms
10,620 KB
testcase_04 AC 139 ms
13,756 KB
testcase_05 AC 103 ms
13,756 KB
testcase_06 AC 99 ms
13,756 KB
testcase_07 AC 139 ms
13,756 KB
testcase_08 AC 142 ms
13,756 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 47 ms
9,996 KB
testcase_13 AC 80 ms
13,596 KB
権限があれば一括ダウンロードができます

ソースコード

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