結果
問題 | No.5001 排他的論理和でランニング |
ユーザー | uafr_cs |
提出日時 | 2018-03-17 03:04:32 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,179 ms / 1,500 ms |
コード長 | 1,897 bytes |
コンパイル時間 | 2,376 ms |
実行使用メモリ | 57,828 KB |
スコア | 52,414,619 |
最終ジャッジ日時 | 2020-03-12 19:58:10 |
ジャッジサーバーID (参考情報) |
judge8 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,156 ms
52,396 KB |
testcase_01 | AC | 813 ms
52,704 KB |
testcase_02 | AC | 854 ms
54,352 KB |
testcase_03 | AC | 981 ms
52,260 KB |
testcase_04 | AC | 1,179 ms
52,296 KB |
testcase_05 | AC | 905 ms
52,204 KB |
testcase_06 | AC | 965 ms
52,224 KB |
testcase_07 | AC | 1,017 ms
54,176 KB |
testcase_08 | AC | 1,124 ms
52,240 KB |
testcase_09 | AC | 771 ms
49,160 KB |
testcase_10 | AC | 871 ms
52,268 KB |
testcase_11 | AC | 928 ms
55,792 KB |
testcase_12 | AC | 847 ms
52,452 KB |
testcase_13 | AC | 1,132 ms
52,188 KB |
testcase_14 | AC | 1,021 ms
52,364 KB |
testcase_15 | AC | 912 ms
52,504 KB |
testcase_16 | AC | 846 ms
52,404 KB |
testcase_17 | AC | 848 ms
54,680 KB |
testcase_18 | AC | 993 ms
52,252 KB |
testcase_19 | AC | 921 ms
55,888 KB |
testcase_20 | AC | 891 ms
52,336 KB |
testcase_21 | AC | 872 ms
52,388 KB |
testcase_22 | AC | 800 ms
54,544 KB |
testcase_23 | AC | 799 ms
50,016 KB |
testcase_24 | AC | 869 ms
57,828 KB |
testcase_25 | AC | 1,015 ms
52,428 KB |
testcase_26 | AC | 974 ms
52,348 KB |
testcase_27 | AC | 891 ms
52,268 KB |
testcase_28 | AC | 1,050 ms
52,192 KB |
testcase_29 | AC | 1,075 ms
52,320 KB |
testcase_30 | AC | 833 ms
52,488 KB |
testcase_31 | AC | 1,027 ms
52,192 KB |
testcase_32 | AC | 889 ms
52,324 KB |
testcase_33 | AC | 1,145 ms
52,608 KB |
testcase_34 | AC | 1,179 ms
52,192 KB |
testcase_35 | AC | 1,034 ms
52,272 KB |
testcase_36 | AC | 1,143 ms
54,160 KB |
testcase_37 | AC | 1,034 ms
52,352 KB |
testcase_38 | AC | 881 ms
55,952 KB |
testcase_39 | AC | 888 ms
56,100 KB |
testcase_40 | AC | 960 ms
52,400 KB |
testcase_41 | AC | 836 ms
54,360 KB |
testcase_42 | AC | 938 ms
52,648 KB |
testcase_43 | AC | 977 ms
52,412 KB |
testcase_44 | AC | 1,096 ms
52,352 KB |
testcase_45 | AC | 1,133 ms
54,456 KB |
testcase_46 | AC | 1,034 ms
52,340 KB |
testcase_47 | AC | 941 ms
52,400 KB |
testcase_48 | AC | 897 ms
56,116 KB |
testcase_49 | AC | 1,121 ms
55,864 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 < 2000000; 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(); } }