結果

問題 No.2024 Xer
ユーザー 37zigen37zigen
提出日時 2022-07-29 22:36:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,752 bytes
コンパイル時間 2,429 ms
コンパイル使用メモリ 77,364 KB
実行使用メモリ 80,384 KB
最終ジャッジ日時 2023-09-26 22:01:21
合計ジャッジ時間 14,676 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
51,344 KB
testcase_01 AC 44 ms
51,148 KB
testcase_02 AC 48 ms
51,228 KB
testcase_03 AC 48 ms
51,328 KB
testcase_04 AC 44 ms
51,232 KB
testcase_05 AC 48 ms
51,288 KB
testcase_06 WA -
testcase_07 AC 663 ms
76,260 KB
testcase_08 AC 392 ms
75,796 KB
testcase_09 AC 184 ms
64,424 KB
testcase_10 AC 357 ms
69,688 KB
testcase_11 AC 321 ms
66,072 KB
testcase_12 AC 429 ms
76,956 KB
testcase_13 AC 397 ms
70,608 KB
testcase_14 AC 655 ms
76,428 KB
testcase_15 AC 344 ms
70,544 KB
testcase_16 AC 493 ms
78,672 KB
testcase_17 AC 197 ms
63,520 KB
testcase_18 AC 320 ms
65,672 KB
testcase_19 AC 578 ms
80,384 KB
testcase_20 AC 184 ms
66,068 KB
testcase_21 AC 224 ms
68,044 KB
testcase_22 AC 225 ms
68,176 KB
testcase_23 AC 227 ms
67,500 KB
testcase_24 AC 230 ms
68,192 KB
testcase_25 AC 57 ms
53,120 KB
testcase_26 AC 78 ms
53,704 KB
testcase_27 AC 74 ms
53,936 KB
testcase_28 AC 57 ms
53,288 KB
testcase_29 AC 56 ms
52,144 KB
testcase_30 AC 77 ms
52,988 KB
testcase_31 AC 80 ms
52,208 KB
testcase_32 AC 93 ms
55,904 KB
testcase_33 AC 77 ms
53,508 KB
testcase_34 AC 54 ms
51,860 KB
testcase_35 AC 46 ms
51,396 KB
testcase_36 AC 74 ms
53,696 KB
testcase_37 AC 78 ms
53,836 KB
testcase_38 AC 81 ms
53,876 KB
testcase_39 AC 54 ms
51,896 KB
testcase_40 AC 58 ms
53,144 KB
testcase_41 AC 82 ms
53,844 KB
testcase_42 AC 77 ms
53,356 KB
testcase_43 AC 82 ms
53,488 KB
testcase_44 AC 79 ms
56,056 KB
testcase_45 AC 147 ms
59,724 KB
testcase_46 AC 87 ms
54,208 KB
testcase_47 AC 135 ms
60,428 KB
testcase_48 AC 47 ms
51,288 KB
testcase_49 AC 48 ms
51,180 KB
testcase_50 AC 48 ms
51,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
	    }
	}
0