結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー uafr_csuafr_cs
提出日時 2015-05-11 21:17:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,667 ms / 5,000 ms
コード長 1,922 bytes
コンパイル時間 2,491 ms
コンパイル使用メモリ 76,232 KB
実行使用メモリ 67,544 KB
最終ジャッジ日時 2023-09-17 16:59:37
合計ジャッジ時間 33,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
49,444 KB
testcase_01 AC 48 ms
49,604 KB
testcase_02 AC 47 ms
49,464 KB
testcase_03 AC 46 ms
49,660 KB
testcase_04 AC 47 ms
49,492 KB
testcase_05 AC 48 ms
49,476 KB
testcase_06 AC 45 ms
49,600 KB
testcase_07 AC 47 ms
49,452 KB
testcase_08 AC 1,211 ms
66,956 KB
testcase_09 AC 513 ms
59,120 KB
testcase_10 AC 1,004 ms
65,476 KB
testcase_11 AC 847 ms
61,844 KB
testcase_12 AC 1,368 ms
67,544 KB
testcase_13 AC 1,507 ms
67,320 KB
testcase_14 AC 965 ms
64,932 KB
testcase_15 AC 1,577 ms
67,156 KB
testcase_16 AC 1,357 ms
66,820 KB
testcase_17 AC 1,477 ms
67,212 KB
testcase_18 AC 47 ms
49,656 KB
testcase_19 AC 44 ms
49,468 KB
testcase_20 AC 279 ms
56,960 KB
testcase_21 AC 1,623 ms
65,388 KB
testcase_22 AC 1,657 ms
67,180 KB
testcase_23 AC 49 ms
49,564 KB
testcase_24 AC 46 ms
49,616 KB
testcase_25 AC 48 ms
49,612 KB
testcase_26 AC 46 ms
49,496 KB
testcase_27 AC 48 ms
49,700 KB
testcase_28 AC 1,048 ms
67,076 KB
testcase_29 AC 1,367 ms
67,028 KB
testcase_30 AC 1,271 ms
67,108 KB
testcase_31 AC 1,093 ms
66,940 KB
testcase_32 AC 1,299 ms
67,016 KB
testcase_33 AC 1,612 ms
67,388 KB
testcase_34 AC 1,622 ms
67,408 KB
testcase_35 AC 1,641 ms
66,980 KB
testcase_36 AC 1,667 ms
67,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		PriorityQueue<Long> queue = new PriorityQueue<Long>(N, Collections.reverseOrder());
		for(int i = 0; i < N; i++){
			queue.add(sc.nextLong());
		}
		
		while(!queue.isEmpty()){
			final long value = queue.poll();
			
			if(value == 0){
				queue.add(value);
				break;
			}else{
				final long min = Long.highestOneBit(value);
			
				while(!queue.isEmpty()){
					final long next_value = queue.poll();
					
					if((next_value & min) != 0){
						queue.add(next_value ^ value);
					}else{
						queue.add(next_value);
						break;
					}
				}
			}
		}
	
		
		final int rank = N - queue.size();
		System.out.println(1l << rank);
	}
	
	public static class Scanner {
	    private BufferedReader br;
	    private StringTokenizer tok;

	    public Scanner(InputStream is) throws IOException {
	        br = new BufferedReader(new InputStreamReader(is));
	    }

	    private void getLine() throws IOException {
	        while (!hasNext()) { tok = new StringTokenizer(br.readLine()); }
	    }

	    private boolean hasNext() {
	        return tok != null && tok.hasMoreTokens();
	    }

	    public String next() throws IOException {
	        getLine(); return tok.nextToken();
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(next());
	    }
	    
	    public long nextLong() throws IOException {
	    	return Long.parseLong(next());
	    }
	    
	    public void close() throws IOException {
	        br.close();
	    }
	}
	
}
0