結果

問題 No.233 めぐるはめぐる (3)
ユーザー furafura
提出日時 2020-07-31 01:18:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 642 ms / 1,000 ms
コード長 598 bytes
コンパイル時間 2,187 ms
コンパイル使用メモリ 206,336 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2023-09-18 12:01:26
合計ジャッジ時間 13,784 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 642 ms
13,508 KB
testcase_01 AC 587 ms
13,472 KB
testcase_02 AC 543 ms
13,520 KB
testcase_03 AC 594 ms
13,516 KB
testcase_04 AC 637 ms
13,516 KB
testcase_05 AC 640 ms
13,588 KB
testcase_06 AC 634 ms
13,532 KB
testcase_07 AC 636 ms
13,524 KB
testcase_08 AC 634 ms
13,520 KB
testcase_09 AC 490 ms
13,468 KB
testcase_10 AC 490 ms
13,592 KB
testcase_11 AC 489 ms
13,536 KB
testcase_12 AC 598 ms
13,760 KB
testcase_13 AC 639 ms
13,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const char* s="inabameguru";
bool used[11];
set<string> res;

bool isvowel(char c){
	return c=='a' || c=='i' || c=='u' || c=='e' || c=='o';
}

void dfs(int S,string t){
	if(S==(1<<11)-1){
		if(isvowel(t.back())) res.emplace(t);
		return;
	}
	rep(i,11) if((S>>i&1)==0) {
		if(t.empty() || isvowel(t.back()) || isvowel(s[i])){
			dfs(S|1<<i,t+s[i]);
		}
	}
}

int main(){
	dfs(0,"");

	int n; cin>>n;
	rep(i,n){
		string t; cin>>t;
		res.erase(t);
	}
	cout<<(res.empty()?"NO":*res.begin())<<'\n';

	return 0;
}
0