結果
問題 | No.5001 排他的論理和でランニング |
ユーザー | uafr_cs |
提出日時 | 2018-03-17 02:52:28 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,277 ms / 1,500 ms |
コード長 | 1,553 bytes |
コンパイル時間 | 2,300 ms |
実行使用メモリ | 56,244 KB |
スコア | 52,428,217 |
最終ジャッジ日時 | 2020-03-12 19:56:53 |
ジャッジサーバーID (参考情報) |
judge10 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,240 ms
52,252 KB |
testcase_01 | AC | 903 ms
54,724 KB |
testcase_02 | AC | 958 ms
54,364 KB |
testcase_03 | AC | 1,067 ms
52,216 KB |
testcase_04 | AC | 1,277 ms
53,872 KB |
testcase_05 | AC | 1,006 ms
52,488 KB |
testcase_06 | AC | 1,062 ms
54,400 KB |
testcase_07 | AC | 1,103 ms
54,356 KB |
testcase_08 | AC | 1,230 ms
54,460 KB |
testcase_09 | AC | 859 ms
52,548 KB |
testcase_10 | AC | 963 ms
55,928 KB |
testcase_11 | AC | 1,028 ms
52,376 KB |
testcase_12 | AC | 958 ms
52,404 KB |
testcase_13 | AC | 1,227 ms
54,348 KB |
testcase_14 | AC | 1,108 ms
52,240 KB |
testcase_15 | AC | 1,021 ms
52,224 KB |
testcase_16 | AC | 948 ms
54,416 KB |
testcase_17 | AC | 978 ms
52,324 KB |
testcase_18 | AC | 1,088 ms
52,244 KB |
testcase_19 | AC | 1,016 ms
52,584 KB |
testcase_20 | AC | 1,007 ms
54,204 KB |
testcase_21 | AC | 964 ms
56,188 KB |
testcase_22 | AC | 885 ms
52,484 KB |
testcase_23 | AC | 877 ms
51,856 KB |
testcase_24 | AC | 954 ms
52,320 KB |
testcase_25 | AC | 1,113 ms
52,264 KB |
testcase_26 | AC | 1,072 ms
54,112 KB |
testcase_27 | AC | 984 ms
54,172 KB |
testcase_28 | AC | 1,124 ms
54,424 KB |
testcase_29 | AC | 1,178 ms
55,940 KB |
testcase_30 | AC | 922 ms
54,300 KB |
testcase_31 | AC | 1,115 ms
54,112 KB |
testcase_32 | AC | 971 ms
52,272 KB |
testcase_33 | AC | 1,253 ms
52,604 KB |
testcase_34 | AC | 1,275 ms
52,360 KB |
testcase_35 | AC | 1,137 ms
54,404 KB |
testcase_36 | AC | 1,224 ms
56,244 KB |
testcase_37 | AC | 1,124 ms
54,556 KB |
testcase_38 | AC | 968 ms
52,528 KB |
testcase_39 | AC | 997 ms
52,272 KB |
testcase_40 | AC | 1,044 ms
52,208 KB |
testcase_41 | AC | 914 ms
52,220 KB |
testcase_42 | AC | 1,022 ms
54,268 KB |
testcase_43 | AC | 1,091 ms
52,252 KB |
testcase_44 | AC | 1,179 ms
54,388 KB |
testcase_45 | AC | 1,199 ms
52,420 KB |
testcase_46 | AC | 1,154 ms
52,396 KB |
testcase_47 | AC | 1,018 ms
52,200 KB |
testcase_48 | AC | 981 ms
54,748 KB |
testcase_49 | AC | 1,173 ms
52,308 KB |
ソースコード
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); int x2 = (int)(Math.random() * N); while(x1 == x2){ x2 = (int)(Math.random() * N); } int x3 = (int)(Math.random() * N); while(x1 == x3 || x2 == x3){ x3 = (int)(Math.random() * N); } int x4 = (int)(Math.random() * N); while(x1 == x4 || x2 == x4 || x3 == x4){ x4 = (int)(Math.random() * N); } int count = 0; count += used[x1] ? 1 : 0; count += used[x2] ? 1 : 0; count += used[x3] ? 1 : 0; count += used[x4] ? 1 : 0; if(count != 2){ continue; } final long next_max = max ^ array[x1] ^ array[x2] ^ array[x3] ^ array[x4]; if(next_max > max){ max = next_max; used[x1] = !used[x1]; used[x2] = !used[x2]; used[x3] = !used[x3]; used[x4] = !used[x4]; } } 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(); } }