結果

問題 No.233 めぐるはめぐる (3)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-03-02 22:10:13
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,303 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 67,760 KB
実行使用メモリ 11,964 KB
最終ジャッジ日時 2023-10-24 19:34:08
合計ジャッジ時間 4,639 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,652 KB
testcase_01 AC 11 ms
7,616 KB
testcase_02 AC 7 ms
5,324 KB
testcase_03 AC 12 ms
7,616 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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


std::string get_available_name(std::vector<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 = std::find(used_names.begin(), used_names.end(), 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::vector<std::string> used_names;
	for (unsigned int i = 0; i < n; i++) {
		std::string s;
		std::cin >> s;
		used_names.push_back(s);
	}
	auto result = get_available_name(used_names);
	std::cout << result << std::endl;

	return EXIT_SUCCESS;
}
0