結果

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

テストケース

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

ソースコード

diff #

import java.util.ArrayList;
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();
		}
		Arrays.sort(array);
		
		boolean[] used = new boolean[N];
		long max = 0;
		for(int i = 0; i < M; i++){
			used[i] = true;
			max ^= array[(N - 1) - i];
		}
		
		for(int x = 0; x < 10000000; x++){
			final int fst = (int)(Math.random() * N);
			final int snd = (int)(Math.random() * N);
			
			final long next_max = max ^ array[fst] ^ array[snd];
			if(next_max > max){
				max = next_max;
				used[fst] = !used[fst];
				used[snd] = !used[snd];
			}
		}
		
		boolean first = true;
		for(int i = 0; i < N; i++){	
			if(!used[i]){ continue; }
			
			System.out.print((first ? "" : " ") + (array[i]));
			first = false;
		}
		System.out.println();
	}
}
0