結果

問題 No.5001 排他的論理和でランニング
ユーザー uafr_csuafr_cs
提出日時 2018-03-17 03:22:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,340 ms / 1,500 ms
コード長 1,917 bytes
コンパイル時間 2,490 ms
実行使用メモリ 56,224 KB
スコア 52,428,633
最終ジャッジ日時 2020-03-12 20:00:05
ジャッジサーバーID
(参考情報)
judge7 /
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,298 ms
54,212 KB
testcase_01 AC 955 ms
52,436 KB
testcase_02 AC 1,009 ms
52,436 KB
testcase_03 AC 1,121 ms
52,292 KB
testcase_04 AC 1,337 ms
54,448 KB
testcase_05 AC 1,047 ms
52,208 KB
testcase_06 AC 1,120 ms
52,244 KB
testcase_07 AC 1,171 ms
52,416 KB
testcase_08 AC 1,260 ms
52,668 KB
testcase_09 AC 908 ms
52,560 KB
testcase_10 AC 1,009 ms
52,292 KB
testcase_11 AC 1,086 ms
52,656 KB
testcase_12 AC 997 ms
52,636 KB
testcase_13 AC 1,278 ms
55,944 KB
testcase_14 AC 1,164 ms
52,576 KB
testcase_15 AC 1,056 ms
54,684 KB
testcase_16 AC 992 ms
52,608 KB
testcase_17 AC 1,039 ms
52,704 KB
testcase_18 AC 1,143 ms
52,316 KB
testcase_19 AC 1,053 ms
54,340 KB
testcase_20 AC 1,023 ms
54,356 KB
testcase_21 AC 1,015 ms
52,316 KB
testcase_22 AC 951 ms
52,336 KB
testcase_23 AC 1,021 ms
53,608 KB
testcase_24 AC 1,002 ms
52,232 KB
testcase_25 AC 1,176 ms
56,224 KB
testcase_26 AC 1,125 ms
52,276 KB
testcase_27 AC 1,032 ms
55,968 KB
testcase_28 AC 1,205 ms
55,920 KB
testcase_29 AC 1,226 ms
52,428 KB
testcase_30 AC 983 ms
52,524 KB
testcase_31 AC 1,185 ms
54,464 KB
testcase_32 AC 1,037 ms
52,412 KB
testcase_33 AC 1,336 ms
54,364 KB
testcase_34 AC 1,340 ms
52,608 KB
testcase_35 AC 1,189 ms
53,836 KB
testcase_36 AC 1,288 ms
54,308 KB
testcase_37 AC 1,200 ms
52,524 KB
testcase_38 AC 1,019 ms
52,492 KB
testcase_39 AC 1,040 ms
55,828 KB
testcase_40 AC 1,111 ms
52,604 KB
testcase_41 AC 973 ms
52,456 KB
testcase_42 AC 1,080 ms
52,400 KB
testcase_43 AC 1,119 ms
52,308 KB
testcase_44 AC 1,237 ms
52,680 KB
testcase_45 AC 1,286 ms
52,232 KB
testcase_46 AC 1,213 ms
52,396 KB
testcase_47 AC 1,074 ms
52,248 KB
testcase_48 AC 1,026 ms
52,692 KB
testcase_49 AC 1,229 ms
52,528 KB
権限があれば一括ダウンロードができます

ソースコード

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[(N - 1) - i] = true;
			max ^= array[(N - 1) - i];
		}
		
		for(int x = 0; x < 4000000; x++){
			final int x1 = (int)(Math.random() * N);
			final int x2 = (int)(Math.random() * N);
			final int x3 = (int)(Math.random() * N);
			final int x4 = (int)(Math.random() * N);
			//final int x5 = (int)(Math.random() * N);
			//final int x6 = (int)(Math.random() * N);
						
			int count = 0;
			count += used[x1] ? 1 : -1; used[x1] = !used[x1];
			count += used[x2] ? 1 : -1; used[x2] = !used[x2];
			count += used[x3] ? 1 : -1; used[x3] = !used[x3];
			count += used[x4] ? 1 : -1; used[x4] = !used[x4];
			//count += used[x5] ? 1 : -1; used[x5] = !used[x5];
			//count += used[x6] ? 1 : -1; used[x6] = !used[x6];
			if(count != 0){
				used[x1] = !used[x1];
				used[x2] = !used[x2];
				used[x3] = !used[x3];
				used[x4] = !used[x4];
				//used[x5] = !used[x5];
				//used[x6] = !used[x6];
				continue;
			}
			
			final long next_max = max ^ array[x1] ^ array[x2] ^ array[x3] ^ array[x4]/* ^ array[x5] ^ array[x6]*/;
			if(next_max > max){
				max = next_max;
			}else{
				used[x1] = !used[x1];
				used[x2] = !used[x2];
				used[x3] = !used[x3];
				used[x4] = !used[x4];
				//used[x5] = !used[x5];
				//used[x6] = !used[x6];
			}
		}
		
		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