結果

問題 No.233 めぐるはめぐる (3)
ユーザー takubokudoritakubokudori
提出日時 2017-08-31 01:47:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 493 ms / 1,000 ms
コード長 1,283 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 97,832 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-04-24 07:26:39
合計ジャッジ時間 4,820 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
13,056 KB
testcase_01 AC 62 ms
9,728 KB
testcase_02 AC 31 ms
6,656 KB
testcase_03 AC 72 ms
10,368 KB
testcase_04 AC 209 ms
13,568 KB
testcase_05 AC 220 ms
13,440 KB
testcase_06 AC 179 ms
13,568 KB
testcase_07 AC 493 ms
13,440 KB
testcase_08 AC 467 ms
13,568 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 70 ms
9,728 KB
testcase_13 AC 118 ms
13,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#define N 1000
#define M 1000000007
#define re(i,n) for(int i=0;i<(n);i++)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fe(i,n,f) for_each(i,n,f)
#define bw(a,b,c) (((a)<=(b))&&((b)<=(c)))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

string a="iaaeuu";
string b="nbmgr";

bool fa[6]={0};
bool fb[5]={0};
int n;
set<string> l;
char dfs(int ap,int bp,bool e,string k){ // if(e)boin
	if(ap==6&&bp==5){
		reverse(k.begin(),k.end());
		// cout<<k<<endl;
		if(l.find(k)==l.end()){cout<<k<<endl;exit(0);};
	}
	// if(ap-bp==3)return 0;
	if(e){
		if(ap<6){
			re(i,6) if(!fa[i]){ fa[i]=true;dfs(ap+1,bp,false,k+a[i]);fa[i]=false;}
		}
	}else{
		if(ap<6)
			re(i,6) if(!fa[i]){ fa[i]=true;dfs(ap+1,bp,false,k+a[i]);fa[i]=false;}
		if(bp<5) re(i,5) if(!fb[i]){fb[i]=true;dfs(ap,bp+1,true,k+b[i]);fb[i]=false;}
	}
	return 0;
}

int main(void){
	string s;
	cin>>n;
	re(i,n)cin>>s,l.insert(s);
	dfs(0,0,true,"");
	cout<<"NO"<<endl;

	return 0;
}
0