結果

問題 No.5001 排他的論理和でランニング
ユーザー uafr_csuafr_cs
提出日時 2018-03-16 22:30:50
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 972 bytes
コンパイル時間 2,297 ms
実行使用メモリ 55,928 KB
スコア 0
最終ジャッジ日時 2020-03-12 19:23:33
ジャッジサーバーID
(参考情報)
judge7 /
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		
		long[] array = new long[N];
		for(int i = 0; i < N; i++){
			array[i] = sc.nextLong();
		}
		
		boolean[] use = new boolean[N];
		long max = 0;
		for(int i = 0; i < M; i++){
			use[i] = true;
			max ^= array[i];
		}
		
		while(true){
			for(int out = 0; out < N; out++){
				if(use[out]){ continue; }
				
				for(int in = 0; in < N; in++){
					if(!use[in]){ continue; }
					
					
					final long next_max = max ^ array[out] ^ array[in];
					if(next_max > max){
						max = next_max;
						use[out] = false;
						use[in] = true;
					}
				}
			}
			
			break;
		}
		
		for(int i = 0; i < N; i++){
			if(!use[i]){ continue; }
			
			System.out.print((i == 0 ? "" : " ") + (array[i]));
		}
		System.out.println();
	}
}
0