結果
問題 | No.233 めぐるはめぐる (3) |
ユーザー | yuki2006 |
提出日時 | 2015-07-20 20:46:55 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,785 bytes |
コンパイル時間 | 2,097 ms |
コンパイル使用メモリ | 74,840 KB |
実行使用メモリ | 76,892 KB |
最終ジャッジ日時 | 2023-09-22 20:41:15 |
合計ジャッジ時間 | 12,893 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 666 ms
75,124 KB |
testcase_01 | AC | 547 ms
54,020 KB |
testcase_02 | AC | 383 ms
50,584 KB |
testcase_03 | AC | 553 ms
54,788 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 739 ms
75,864 KB |
testcase_08 | AC | 690 ms
62,920 KB |
testcase_09 | AC | 121 ms
55,608 KB |
testcase_10 | AC | 120 ms
55,276 KB |
testcase_11 | AC | 120 ms
55,748 KB |
testcase_12 | AC | 549 ms
67,024 KB |
testcase_13 | AC | 670 ms
62,564 KB |
ソースコード
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 boolean check(char[] a,int length) { for (int i = 0; i < length; i++) { if (!is_vowel(a[i]) && !is_vowel(a[i + 1])) { return false; } } return true; } static char[] moji = {'i', 'n', 'a', 'b', 'a', 'm', 'e', 'g', 'u', 'r', 'u'};//11moji static void func(char[] now, int current, int used) { if (Integer.bitCount(used) == 11) { if (!set.contains(new String(now)) && is_vowel(now[10])) { System.out.println(now); System.exit(0); } else { return; } } for (int i = 0; i < 11; i++) { if ((used >> i & 1) == 0) { if (((used >> 2 & 1) == 0 && (used >> 4 & 1) > 0) || ((used >> 8 & 1) == 0 && (used >> 10 & 1) > 0)) return; if ((used >> 0 & 1) > 0 && (used >> 2 & 1) > 0 && (used >> 4 & 1) > 0 && (used >> 6 & 1) > 0 && (used >> 8 & 1) > 0 && (used >> 10 & 1) > 0) return; if (!check(now,current)) continue; used += 1 << i; now[current] = moji[i]; func(now, 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(new char[11], 0, 0); System.out.println("NO"); } }