結果
問題 | No.233 めぐるはめぐる (3) |
ユーザー | yuki2006 |
提出日時 | 2015-07-21 12:10:51 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,498 bytes |
コンパイル時間 | 2,180 ms |
コンパイル使用メモリ | 74,860 KB |
実行使用メモリ | 87,116 KB |
最終ジャッジ日時 | 2023-09-22 22:58:20 |
合計ジャッジ時間 | 15,469 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 712 ms
76,272 KB |
testcase_01 | AC | 545 ms
67,928 KB |
testcase_02 | AC | 368 ms
64,004 KB |
testcase_03 | AC | 541 ms
66,324 KB |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | AC | 120 ms
55,540 KB |
testcase_10 | AC | 118 ms
55,752 KB |
testcase_11 | AC | 116 ms
55,744 KB |
testcase_12 | AC | 537 ms
68,216 KB |
testcase_13 | AC | 730 ms
76,800 KB |
ソースコード
import java.util.*; public class Main { static HashSet<String> set; static final char[] moji = {'i', 'n', 'a', 'b', 'a', 'm', 'e', 'g', 'u', 'r', 'u'};//11moji static void func(char[] now, int used, int current, 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; } int step = 1; // 子音の後は、母音しか選べないのでうまいこと2つとばしになっている。 if (prevNotVowel) { step = 2; } for (int i = 0; i < 11; i += step) { final int bit = 1 << i; if ((used & bit) > 0) { continue; } // 選んだものが子音じゃないか判定 boolean isNotVowel = (bit & 0b01010101010) > 0; now[current] = moji[i]; func(now, used | bit, current + 1, isNotVowel); } } 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(new char[11], 0, 0, false); System.out.println("NO"); } }