結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー | tenten |
提出日時 | 2023-02-15 08:47:10 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 361 ms / 5,000 ms |
コード長 | 2,006 bytes |
コンパイル時間 | 5,321 ms |
コンパイル使用メモリ | 80,820 KB |
実行使用メモリ | 57,372 KB |
最終ジャッジ日時 | 2023-09-24 18:42:01 |
合計ジャッジ時間 | 9,707 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
49,104 KB |
testcase_01 | AC | 51 ms
49,332 KB |
testcase_02 | AC | 70 ms
51,276 KB |
testcase_03 | AC | 59 ms
51,064 KB |
testcase_04 | AC | 49 ms
49,188 KB |
testcase_05 | AC | 63 ms
51,472 KB |
testcase_06 | AC | 67 ms
50,988 KB |
testcase_07 | AC | 361 ms
56,752 KB |
testcase_08 | AC | 292 ms
57,372 KB |
testcase_09 | AC | 215 ms
56,420 KB |
testcase_10 | AC | 262 ms
56,444 KB |
testcase_11 | AC | 298 ms
56,516 KB |
testcase_12 | AC | 72 ms
49,748 KB |
testcase_13 | AC | 45 ms
49,408 KB |
testcase_14 | AC | 313 ms
56,600 KB |
testcase_15 | AC | 350 ms
56,972 KB |
testcase_16 | AC | 59 ms
50,944 KB |
testcase_17 | AC | 159 ms
56,228 KB |
testcase_18 | AC | 318 ms
57,140 KB |
testcase_19 | AC | 161 ms
56,028 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); boolean[] dp = new boolean[1 << 15]; dp[0] = true; for (int i = 0; i < n; i++) { int x = sc.nextInt(); boolean[] next = new boolean[1 << 15]; for (int j = 0; j < next.length; j++) { next[j ^ x] = dp[j]; } for (int j = 0; j < next.length; j++) { dp[j] |= next[j]; } } int count = 0; for (boolean x : dp) { if (x) { count++; } } System.out.println(count); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }