結果

問題 No.233 めぐるはめぐる (3)
ユーザー masamasa
提出日時 2015-06-28 22:11:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 167 ms / 1,000 ms
コード長 936 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 75,004 KB
実行使用メモリ 13,628 KB
最終ジャッジ日時 2023-09-22 04:05:49
合計ジャッジ時間 4,119 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
13,112 KB
testcase_01 AC 70 ms
9,656 KB
testcase_02 AC 32 ms
6,508 KB
testcase_03 AC 79 ms
10,552 KB
testcase_04 AC 167 ms
13,464 KB
testcase_05 AC 143 ms
13,496 KB
testcase_06 AC 129 ms
13,524 KB
testcase_07 AC 162 ms
13,480 KB
testcase_08 AC 163 ms
13,628 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 71 ms
9,716 KB
testcase_13 AC 121 ms
13,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>

using namespace std;

int main() {
	int n;
	string name;

	cin >> n;

	set<string> names;
	for (int i = 0; i < n; i++) {
		cin >> name;
		names.insert(name);
	}

	string boin  =  "nbmgr";
	string shiin = "iaaeuu";
	int n_boin = boin.size();
	int n_shiin = shiin.size();

	sort(boin.begin(), boin.end());
	sort(shiin.begin(), shiin.end());

	do {
		do {
			for (int i = 0; i < n_shiin; i++) {
				name.clear();
				int idx_b = 0;

				for (int j = 0; j < n_shiin; j++) {
					if (j != i) {
						name += boin[idx_b];
						idx_b++;
					}
					name += shiin[j];
				}

				if (names.count(name) == 0) {
					cout << name << endl;
					return 0;
				}
			}

		} while (next_permutation(boin.begin(), boin.end()));
	} while (next_permutation(shiin.begin(), shiin.end()));

	cout << "NO" << endl;
	return 0;
}
0