結果

問題 No.233 めぐるはめぐる (3)
ユーザー kou6839kou6839
提出日時 2015-07-20 14:51:10
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,183 bytes
コンパイル時間 2,282 ms
コンパイル使用メモリ 81,424 KB
実行使用メモリ 85,548 KB
最終ジャッジ日時 2023-09-22 20:35:04
合計ジャッジ時間 16,139 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 818 ms
78,016 KB
testcase_01 AC 633 ms
68,108 KB
testcase_02 AC 472 ms
64,860 KB
testcase_03 AC 665 ms
68,700 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 AC 217 ms
60,300 KB
testcase_10 AC 216 ms
59,708 KB
testcase_11 AC 156 ms
56,448 KB
testcase_12 AC 614 ms
68,564 KB
testcase_13 AC 822 ms
80,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static HashSet<String> set;
	static boolean is_boin (char a){
		if(a=='a'||a=='i'||a=='u'||a=='e'||a=='o') return true;
		return false;
	}
	static boolean check(String a){
		if( a.length()==11){
		char last_char = a.charAt(10);
		if(!is_boin(last_char)){
			return false;
		}}
		
		for(int i=0;i<a.length()-1;i++){
			if(!is_boin(a.charAt(i)) && !is_boin(a.charAt(i+1))){
				return false;
			}
		}
		return true;
	}
	static char[] moji = {'i','n','a','b','a','m','e','g','u','r','u'};//11moji
	
	static void func(String now,int used){
		if(Integer.bitCount(used)==11){
			if(!set.contains(now) && check(now)){
				System.out.println(now);
				System.exit(0);
			}else{
				return;
			}
		}
		String moto = new String(now);
		for(int i=0;i<11;i++){
			if((used >> i & 1) == 0){
				now+=moji[i];
				used+=1<<i;
				if(!check(now)) continue;
				func(now, used);
				now=new String(moto);
				used-=1<<i;
			}
		}
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		set = new HashSet<>();
		for(int i=0;i<N;i++)set.add(sc.next());
		func("", 0);
		System.out.println("NO");
	}
}
0