結果

問題 No.233 めぐるはめぐる (3)
ユーザー yuki2006yuki2006
提出日時 2015-07-20 21:47:44
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,615 bytes
コンパイル時間 1,977 ms
コンパイル使用メモリ 74,664 KB
実行使用メモリ 86,020 KB
最終ジャッジ日時 2023-09-22 20:46:31
合計ジャッジ時間 15,113 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 685 ms
77,964 KB
testcase_01 AC 516 ms
68,380 KB
testcase_02 AC 378 ms
63,708 KB
testcase_03 AC 580 ms
68,040 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 AC 122 ms
55,432 KB
testcase_10 AC 126 ms
55,436 KB
testcase_11 AC 124 ms
55,396 KB
testcase_12 AC 533 ms
68,064 KB
testcase_13 AC 691 ms
76,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 int used = 0;
    static int current = 0;

    static void func(boolean prevNotVowel) {
        if (current == 11) {
            if (!set.contains(new String(now))) {
                System.out.println(now);
                System.exit(0);
            } else {
                return;
            }
        }
        if ((used & 0b10101010101) == 0b10101010101) {
            return;
        }

        for (int i = 0; i < 11; i++) {
            if ((used >> i & 1) > 0) {
                continue;
            }
            if (prevNotVowel && ((1 << i) & 0b01010101010) > 0) {
                continue;
            }

//                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;
            current++;
            func(((1 << i) & 0b01010101010) > 0);
            current--;
            used &= ~(1 << i);
        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        set = new HashSet<>(N);
        for (int i = 0; i < N; i++) set.add(sc.next());
        func(false);
        System.out.println("NO");
    }
}
0