結果
問題 | No.2024 Xer |
ユーザー | 37zigen |
提出日時 | 2022-07-29 22:36:56 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,752 bytes |
コンパイル時間 | 2,270 ms |
コンパイル使用メモリ | 79,256 KB |
実行使用メモリ | 81,728 KB |
最終ジャッジ日時 | 2024-07-19 15:48:44 |
合計ジャッジ時間 | 12,897 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
36,952 KB |
testcase_01 | AC | 51 ms
36,876 KB |
testcase_02 | AC | 51 ms
37,004 KB |
testcase_03 | AC | 52 ms
36,844 KB |
testcase_04 | AC | 52 ms
36,876 KB |
testcase_05 | AC | 51 ms
36,864 KB |
testcase_06 | WA | - |
testcase_07 | AC | 636 ms
73,848 KB |
testcase_08 | AC | 627 ms
81,728 KB |
testcase_09 | AC | 189 ms
52,456 KB |
testcase_10 | AC | 339 ms
67,412 KB |
testcase_11 | AC | 244 ms
50,620 KB |
testcase_12 | AC | 384 ms
61,940 KB |
testcase_13 | AC | 387 ms
58,744 KB |
testcase_14 | AC | 533 ms
64,232 KB |
testcase_15 | AC | 349 ms
56,312 KB |
testcase_16 | AC | 450 ms
59,156 KB |
testcase_17 | AC | 174 ms
48,712 KB |
testcase_18 | AC | 323 ms
55,416 KB |
testcase_19 | AC | 512 ms
70,860 KB |
testcase_20 | AC | 235 ms
55,480 KB |
testcase_21 | AC | 226 ms
55,288 KB |
testcase_22 | AC | 228 ms
54,940 KB |
testcase_23 | AC | 219 ms
55,448 KB |
testcase_24 | AC | 217 ms
55,044 KB |
testcase_25 | AC | 63 ms
37,640 KB |
testcase_26 | AC | 77 ms
38,364 KB |
testcase_27 | AC | 80 ms
39,640 KB |
testcase_28 | AC | 64 ms
37,844 KB |
testcase_29 | AC | 71 ms
37,824 KB |
testcase_30 | AC | 73 ms
38,380 KB |
testcase_31 | AC | 78 ms
38,696 KB |
testcase_32 | AC | 79 ms
41,492 KB |
testcase_33 | AC | 73 ms
38,060 KB |
testcase_34 | AC | 57 ms
37,672 KB |
testcase_35 | AC | 54 ms
37,020 KB |
testcase_36 | AC | 72 ms
38,256 KB |
testcase_37 | AC | 75 ms
38,400 KB |
testcase_38 | AC | 79 ms
38,836 KB |
testcase_39 | AC | 57 ms
37,632 KB |
testcase_40 | AC | 64 ms
37,620 KB |
testcase_41 | AC | 81 ms
39,936 KB |
testcase_42 | AC | 74 ms
38,120 KB |
testcase_43 | AC | 83 ms
40,200 KB |
testcase_44 | AC | 75 ms
40,828 KB |
testcase_45 | AC | 144 ms
46,788 KB |
testcase_46 | AC | 97 ms
39,700 KB |
testcase_47 | AC | 134 ms
46,088 KB |
testcase_48 | AC | 55 ms
37,128 KB |
testcase_49 | AC | 52 ms
36,992 KB |
testcase_50 | AC | 53 ms
36,892 KB |
ソースコード
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.NoSuchElementException; public class Main implements Runnable { public static void main(String[] args) { new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start(); } final long mod = 998244353; long pow(long a, long n) { if (n == 0) return 1; return pow(a * a % mod, n / 2) * (n % 2 == 1 ? a : 1) % mod; } long inv(long a) { return pow(a, mod - 2); } boolean f(ArrayList<Integer> a, int X, int bit) { if (a.size() <= 1) return true; if (bit < 0) return false; if ((X >> bit) % 2 == 1) { int c0 = 0; int c1 = 0; for (int v : a) { if ((v >> bit) % 2 == 0) ++c0; else ++c1; } return Math.abs(c0 - c1) <= 1; } else { ArrayList<Integer> e = new ArrayList<>(); ArrayList<Integer> o = new ArrayList<>(); for (int v : a) { if ((v >> bit) % 2 == 0) e.add(v); else o.add(v); } return f(e, X, bit-1) && f(o, X, bit-1); } } public void run() { FastScanner sc=new FastScanner(); PrintWriter pw=new PrintWriter(System.out); int N=sc.nextInt(); int X=sc.nextInt(); int[] A = new int[N]; ArrayList<Integer> a = new ArrayList<>(); for (int i=0;i<N;++i) { A[i]=sc.nextInt(); a.add(A[i]); } System.out.println(f(a, X, 29) ? "Yes" : "No"); pw.close(); } void tr(Object...objects) {System.err.println(Arrays.deepToString(objects));} } class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;} private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;} public boolean hasNext() { skipUnprintable(); return hasNextByte();} public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { return (int)nextLong(); } }