結果
問題 | No.5001 排他的論理和でランニング |
ユーザー | uafr_cs |
提出日時 | 2018-03-17 03:10:47 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,022 ms / 1,500 ms |
コード長 | 1,917 bytes |
コンパイル時間 | 2,297 ms |
実行使用メモリ | 56,316 KB |
スコア | 52,428,290 |
最終ジャッジ日時 | 2020-03-12 19:58:52 |
ジャッジサーバーID (参考情報) |
judge10 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 987 ms
55,956 KB |
testcase_01 | AC | 654 ms
54,124 KB |
testcase_02 | AC | 692 ms
52,560 KB |
testcase_03 | AC | 805 ms
54,260 KB |
testcase_04 | AC | 1,022 ms
52,336 KB |
testcase_05 | AC | 741 ms
54,584 KB |
testcase_06 | AC | 819 ms
52,360 KB |
testcase_07 | AC | 841 ms
52,244 KB |
testcase_08 | AC | 971 ms
52,392 KB |
testcase_09 | AC | 604 ms
50,984 KB |
testcase_10 | AC | 724 ms
55,936 KB |
testcase_11 | AC | 771 ms
54,440 KB |
testcase_12 | AC | 696 ms
52,200 KB |
testcase_13 | AC | 970 ms
52,440 KB |
testcase_14 | AC | 845 ms
52,412 KB |
testcase_15 | AC | 736 ms
55,856 KB |
testcase_16 | AC | 675 ms
52,336 KB |
testcase_17 | AC | 715 ms
54,464 KB |
testcase_18 | AC | 824 ms
52,236 KB |
testcase_19 | AC | 746 ms
52,288 KB |
testcase_20 | AC | 713 ms
53,856 KB |
testcase_21 | AC | 710 ms
52,716 KB |
testcase_22 | AC | 639 ms
54,352 KB |
testcase_23 | AC | 636 ms
50,020 KB |
testcase_24 | AC | 711 ms
52,372 KB |
testcase_25 | AC | 857 ms
52,388 KB |
testcase_26 | AC | 811 ms
54,180 KB |
testcase_27 | AC | 736 ms
52,264 KB |
testcase_28 | AC | 885 ms
52,316 KB |
testcase_29 | AC | 888 ms
52,352 KB |
testcase_30 | AC | 668 ms
52,472 KB |
testcase_31 | AC | 869 ms
54,280 KB |
testcase_32 | AC | 719 ms
54,388 KB |
testcase_33 | AC | 989 ms
52,252 KB |
testcase_34 | AC | 1,010 ms
55,876 KB |
testcase_35 | AC | 860 ms
56,316 KB |
testcase_36 | AC | 966 ms
52,612 KB |
testcase_37 | AC | 870 ms
52,584 KB |
testcase_38 | AC | 724 ms
52,708 KB |
testcase_39 | AC | 732 ms
52,632 KB |
testcase_40 | AC | 788 ms
52,236 KB |
testcase_41 | AC | 660 ms
52,636 KB |
testcase_42 | AC | 782 ms
52,576 KB |
testcase_43 | AC | 805 ms
55,812 KB |
testcase_44 | AC | 911 ms
52,368 KB |
testcase_45 | AC | 954 ms
52,276 KB |
testcase_46 | AC | 899 ms
52,600 KB |
testcase_47 | AC | 750 ms
54,648 KB |
testcase_48 | AC | 711 ms
52,444 KB |
testcase_49 | AC | 935 ms
52,352 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(); } }