結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,332 KB
testcase_01 AC 43 ms
49,224 KB
testcase_02 AC 45 ms
49,444 KB
testcase_03 AC 44 ms
49,276 KB
testcase_04 AC 45 ms
49,328 KB
testcase_05 AC 44 ms
49,176 KB
testcase_06 AC 44 ms
49,356 KB
testcase_07 AC 45 ms
49,444 KB
testcase_08 AC 283 ms
57,872 KB
testcase_09 AC 163 ms
54,580 KB
testcase_10 AC 247 ms
53,416 KB
testcase_11 AC 226 ms
55,712 KB
testcase_12 AC 301 ms
58,760 KB
testcase_13 AC 310 ms
58,596 KB
testcase_14 AC 247 ms
55,276 KB
testcase_15 AC 314 ms
60,032 KB
testcase_16 AC 298 ms
58,016 KB
testcase_17 AC 313 ms
58,644 KB
testcase_18 AC 46 ms
49,188 KB
testcase_19 AC 43 ms
49,272 KB
testcase_20 AC 208 ms
55,764 KB
testcase_21 AC 319 ms
60,832 KB
testcase_22 AC 318 ms
60,644 KB
testcase_23 AC 46 ms
49,156 KB
testcase_24 AC 45 ms
49,268 KB
testcase_25 AC 45 ms
49,192 KB
testcase_26 AC 44 ms
49,280 KB
testcase_27 AC 45 ms
49,228 KB
testcase_28 AC 269 ms
57,452 KB
testcase_29 AC 299 ms
58,872 KB
testcase_30 AC 283 ms
57,716 KB
testcase_31 AC 273 ms
57,416 KB
testcase_32 AC 296 ms
57,988 KB
testcase_33 AC 302 ms
60,208 KB
testcase_34 AC 322 ms
60,300 KB
testcase_35 AC 320 ms
60,668 KB
testcase_36 AC 324 ms
60,756 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();
		long[] inputs = new long[N];
		for(int i = 0; i < N; i++){
			inputs[i] = sc.nextLong();
		}
		
		final int SIZE = 64;
		long[] pivot = new long[SIZE + 1];
		for(int i = 0; i < N; i++){
			long value = inputs[i];
			
			for(int bit = SIZE; bit >= 0; bit--){
				if((value & (1l << bit)) == 0){
					continue;
				}
				
				if(pivot[bit] == 0){
					pivot[bit] = value;
					break;
				}else{
					value ^= pivot[bit];
				}
			}
		}
		
		int rank = SIZE + 1;
		for(int i = 0; i <= SIZE; i++){
			if(pivot[i] == 0){
				rank--;
			}
		}
		
		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