結果

問題 No.233 めぐるはめぐる (3)
ユーザー kongarishisyamo
提出日時 2016-02-29 01:15:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 229 ms / 1,000 ms
コード長 1,260 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 68,272 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-09-24 12:28:40
合計ジャッジ時間 5,718 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<set>

using namespace std;

void make1(string s);
void make2(string s);
void make3(string s);

set<string> name;
int n=0,a=0,b=0,m=0,e=0,g=0,u=0,r=0,i=0;

void make3(string s){
	string in="";
	if(i!=1) in="i";
	else if(a!=2) in="a";
	else if(u!=2) in="u";
	else if(e!=1) in="e";
	for(int ii=0;ii<s.size()+1;ii++){
		string setin="";
		int j;
		for(j=0;j<s.size();j++){
			if(ii==j) setin+=in;
			setin+=s[j];
		}
		if(ii==j) setin+=in;
		name.insert(setin);
	}

}

void make2(string s){
	if(s.size()!=10){
		if(a!=2){
			a++;
			make1(s+'a');
			a--;
		}
		if(i!=1){
			i++;
			make1(s+'i');
			i--;
		}
		if(e!=1){
			e++;
			make1(s+'e');
			e--;
		}
		if(u!=2){
			u++;
			make1(s+'u');
			u--;
		}
	}
	else make3(s);
}

void make1(string s){
	if(s.size()!=10){
		if(n!=1){
			n++;
			make2(s+'n');
			n--;
		}
		if(b!=1){
			b++;
			make2(s+'b');
			b--;
		}
		if(m!=1){
			m++;
			make2(s+'m');
			m--;
		}
		if(g!=1){
			g++;
			make2(s+'g');
			g--;
		}
		if(r!=1){
			r++;
			make2(s+'r');
			r--;
		}
	}
	else make3(s);
}

int main(){

	int N;
	string s;

	make1("");

	cin>>N;

	for(int i=0;i<N;i++){
		cin>>s;
		name.erase(s);
	}

	if(name.size()>0) cout<<*(name.begin())<<endl;
	else cout<<"NO"<<endl;
}
0