結果
問題 |
No.233 めぐるはめぐる (3)
|
ユーザー |
![]() |
提出日時 | 2015-07-20 14:47:28 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,116 bytes |
コンパイル時間 | 3,019 ms |
コンパイル使用メモリ | 81,836 KB |
実行使用メモリ | 77,652 KB |
最終ジャッジ日時 | 2024-07-08 11:13:23 |
合計ジャッジ時間 | 10,651 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 4 TLE * 1 -- * 6 |
ソースコード
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){ char last_char = a.charAt(10); if(!is_boin(last_char)){ return false; } for(int i=0;i<10;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; 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"); } }