結果
| 問題 |
No.233 めぐるはめぐる (3)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-20 21:17:05 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,622 bytes |
| コンパイル時間 | 2,598 ms |
| コンパイル使用メモリ | 85,048 KB |
| 実行使用メモリ | 73,672 KB |
| 最終ジャッジ日時 | 2024-07-08 11:22:50 |
| 合計ジャッジ時間 | 13,906 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 5 |
ソースコード
import java.util.*;
public class Main {
static HashSet<String> set;
static boolean is_vowel(char a) {
if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o') return true;
return false;
}
static char[] moji = {'i', 'n', 'a', 'b', 'a', 'm', 'e', 'g', 'u', 'r', 'u'};//11moji
static char[] now = new char[11];
static void func(int current, int used) {
if (current == 11) {
if (!set.contains(new String(now))) {
System.out.println(now);
System.exit(0);
} else {
return;
}
}
if ((used & 0b10101010101) == 0b10101010101) {
return;
}
boolean prevNotVowel = false;
if (current > 0) {
prevNotVowel = !is_vowel(now[current - 1]);
}
for (int i = 0; i < 11; i++) {
if (prevNotVowel && ((1 << i) & 0b01010101010) > 0) {
continue;
}
if ((used >> i & 1) == 0) {
// if (((used >> 2 & 1) == 0 && (used >> 4 & 1) > 0) || ((used >> 8 & 1) == 0 && (used >> 10 & 1) > 0))
// return;
now[current] = moji[i];
used |= 1 << i;
func(current + 1, used);
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, 0);
System.out.println("NO");
}
}