結果

問題 No.233 めぐるはめぐる (3)
ユーザー IL_mstaIL_msta
提出日時 2015-06-27 02:50:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 133 ms / 1,000 ms
コード長 1,774 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 97,772 KB
実行使用メモリ 13,736 KB
最終ジャッジ日時 2023-09-22 03:04:58
合計ジャッジ時間 3,488 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
13,116 KB
testcase_01 AC 48 ms
9,780 KB
testcase_02 AC 22 ms
6,540 KB
testcase_03 AC 57 ms
10,404 KB
testcase_04 AC 133 ms
13,544 KB
testcase_05 AC 106 ms
13,736 KB
testcase_06 AC 100 ms
13,488 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 47 ms
9,924 KB
testcase_13 AC 83 ms
13,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
const int inmax = 129600;//(518400/4);
//string name[inmax];
string name;
set<string> nameSet;
int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(6);//
	
	LL N;
	cin>>N;
	if(N>=inmax){
		P("NO");
		return 0;
	}
	else if(N==0){
		P("inabameguru");
		return 0;
	}
	rep(i,N){
		cin>>name;
		nameSet.insert(name);
	}
	///////////////
	//inabameguru
	//nbmgr
	//iaaeuu
	int siMax = 5;
	vector<char> si;
	si.push_back('n');
	si.push_back('b');
	si.push_back('m');
	si.push_back('g');
	si.push_back('r');
	sort(si.begin(),si.end());
	
	int boMax = 6;
	vector<char> bo;
	bo.push_back('a');
    bo.push_back('a');
    bo.push_back('i');
    bo.push_back('u');
    bo.push_back('u');
    bo.push_back('e');
	sort(bo.begin(),bo.end());
	
	string temp;
	pair<set<string>::iterator,bool> kekka;
	do{
		do{
			for(int k=0;k<siMax+1;++k){
				for(int i=0;i<siMax;++i){
					if(i==k){
						temp += (bo[boMax-1]);
					}
					temp += (si[i]);
					temp += (bo[i]);
				}
				if(k==boMax-1){
					temp += (bo[boMax-1]);
				}
				kekka = nameSet.insert(temp);
				if(kekka.second == true){
					P( *(kekka.first) );
					return 0;
				}
				temp = "";
			}
		}while( next_permutation( bo.begin(), bo.end() ) );
	}while( next_permutation(si.begin(), si.end()) );
	P("NO");
	return 0;
}
0