結果
問題 | No.5001 排他的論理和でランニング |
ユーザー | uafr_cs |
提出日時 | 2018-03-17 03:44:08 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,392 ms / 1,500 ms |
コード長 | 2,218 bytes |
コンパイル時間 | 2,249 ms |
実行使用メモリ | 56,292 KB |
スコア | 52,061,644 |
最終ジャッジ日時 | 2020-03-12 20:03:47 |
ジャッジサーバーID (参考情報) |
judge8 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,354 ms
52,484 KB |
testcase_01 | AC | 965 ms
52,328 KB |
testcase_02 | AC | 1,034 ms
54,540 KB |
testcase_03 | AC | 1,155 ms
52,348 KB |
testcase_04 | AC | 1,392 ms
52,176 KB |
testcase_05 | AC | 1,057 ms
54,424 KB |
testcase_06 | AC | 1,136 ms
52,272 KB |
testcase_07 | AC | 1,186 ms
52,364 KB |
testcase_08 | AC | 1,258 ms
52,376 KB |
testcase_09 | AC | 936 ms
50,732 KB |
testcase_10 | AC | 1,010 ms
52,500 KB |
testcase_11 | AC | 1,076 ms
52,312 KB |
testcase_12 | AC | 998 ms
52,356 KB |
testcase_13 | AC | 1,282 ms
52,228 KB |
testcase_14 | AC | 1,201 ms
52,372 KB |
testcase_15 | AC | 1,091 ms
52,296 KB |
testcase_16 | AC | 1,033 ms
52,648 KB |
testcase_17 | AC | 1,011 ms
52,408 KB |
testcase_18 | AC | 1,160 ms
54,268 KB |
testcase_19 | AC | 1,082 ms
54,272 KB |
testcase_20 | AC | 1,064 ms
52,392 KB |
testcase_21 | AC | 1,019 ms
54,436 KB |
testcase_22 | AC | 954 ms
52,452 KB |
testcase_23 | AC | 966 ms
49,868 KB |
testcase_24 | AC | 999 ms
54,404 KB |
testcase_25 | AC | 1,176 ms
52,152 KB |
testcase_26 | AC | 1,132 ms
52,612 KB |
testcase_27 | AC | 1,020 ms
52,212 KB |
testcase_28 | AC | 1,237 ms
52,180 KB |
testcase_29 | AC | 1,262 ms
52,696 KB |
testcase_30 | AC | 1,020 ms
52,524 KB |
testcase_31 | AC | 1,202 ms
52,436 KB |
testcase_32 | AC | 1,056 ms
52,432 KB |
testcase_33 | AC | 1,352 ms
52,200 KB |
testcase_34 | AC | 1,361 ms
53,912 KB |
testcase_35 | AC | 1,222 ms
54,432 KB |
testcase_36 | AC | 1,319 ms
54,324 KB |
testcase_37 | AC | 1,202 ms
52,456 KB |
testcase_38 | AC | 1,051 ms
54,108 KB |
testcase_39 | AC | 1,048 ms
52,228 KB |
testcase_40 | AC | 1,167 ms
55,884 KB |
testcase_41 | AC | 1,000 ms
52,196 KB |
testcase_42 | AC | 1,113 ms
56,292 KB |
testcase_43 | AC | 1,173 ms
52,416 KB |
testcase_44 | AC | 1,272 ms
52,536 KB |
testcase_45 | AC | 1,320 ms
52,232 KB |
testcase_46 | AC | 1,221 ms
52,244 KB |
testcase_47 | AC | 1,122 ms
52,220 KB |
testcase_48 | AC | 1,066 ms
56,012 KB |
testcase_49 | AC | 1,245 ms
55,900 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); final int x7 = (int)(Math.random() * N); final int x8 = (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]; count += used[x7] ? 1 : -1; used[x7] = !used[x7]; count += used[x8] ? 1 : -1; used[x8] = !used[x8]; 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]; used[x7] = !used[x7]; used[x8] = !used[x8]; continue; } final long next_max = max ^ array[x1] ^ array[x2] ^ array[x3] ^ array[x4]^ array[x5] ^ array[x6] ^ array[x7] ^ array[x8]; 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]; used[x7] = !used[x7]; used[x8] = !used[x8]; } } 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(); } }