結果
問題 | No.5001 排他的論理和でランニング |
ユーザー | 37zigen |
提出日時 | 2018-03-25 17:40:32 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,474 ms / 1,500 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 2,203 ms |
実行使用メモリ | 56,104 KB |
スコア | 52,428,729 |
最終ジャッジ日時 | 2020-03-12 20:54:20 |
ジャッジサーバーID (参考情報) |
judge9 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,442 ms
52,324 KB |
testcase_01 | AC | 1,052 ms
52,476 KB |
testcase_02 | AC | 1,134 ms
52,316 KB |
testcase_03 | AC | 1,253 ms
52,268 KB |
testcase_04 | AC | 1,474 ms
54,256 KB |
testcase_05 | AC | 1,152 ms
54,332 KB |
testcase_06 | AC | 1,260 ms
52,348 KB |
testcase_07 | AC | 1,298 ms
52,448 KB |
testcase_08 | AC | 1,377 ms
52,468 KB |
testcase_09 | AC | 992 ms
51,384 KB |
testcase_10 | AC | 1,092 ms
52,456 KB |
testcase_11 | AC | 1,189 ms
52,256 KB |
testcase_12 | AC | 1,115 ms
54,040 KB |
testcase_13 | AC | 1,391 ms
54,176 KB |
testcase_14 | AC | 1,304 ms
52,264 KB |
testcase_15 | AC | 1,193 ms
52,544 KB |
testcase_16 | AC | 1,108 ms
52,344 KB |
testcase_17 | AC | 1,083 ms
52,324 KB |
testcase_18 | AC | 1,260 ms
52,492 KB |
testcase_19 | AC | 1,178 ms
52,460 KB |
testcase_20 | AC | 1,165 ms
52,248 KB |
testcase_21 | AC | 1,107 ms
52,204 KB |
testcase_22 | AC | 1,028 ms
54,564 KB |
testcase_23 | AC | 1,042 ms
49,776 KB |
testcase_24 | AC | 1,093 ms
52,248 KB |
testcase_25 | AC | 1,309 ms
52,300 KB |
testcase_26 | AC | 1,255 ms
52,220 KB |
testcase_27 | AC | 1,122 ms
54,136 KB |
testcase_28 | AC | 1,360 ms
52,156 KB |
testcase_29 | AC | 1,372 ms
54,340 KB |
testcase_30 | AC | 1,104 ms
52,196 KB |
testcase_31 | AC | 1,322 ms
52,272 KB |
testcase_32 | AC | 1,156 ms
52,552 KB |
testcase_33 | AC | 1,463 ms
52,532 KB |
testcase_34 | AC | 1,452 ms
52,404 KB |
testcase_35 | AC | 1,328 ms
52,316 KB |
testcase_36 | AC | 1,436 ms
52,516 KB |
testcase_37 | AC | 1,300 ms
52,216 KB |
testcase_38 | AC | 1,161 ms
56,104 KB |
testcase_39 | AC | 1,143 ms
54,644 KB |
testcase_40 | AC | 1,238 ms
52,508 KB |
testcase_41 | AC | 1,076 ms
54,300 KB |
testcase_42 | AC | 1,206 ms
52,292 KB |
testcase_43 | AC | 1,246 ms
52,292 KB |
testcase_44 | AC | 1,382 ms
55,884 KB |
testcase_45 | AC | 1,420 ms
54,216 KB |
testcase_46 | AC | 1,326 ms
52,128 KB |
testcase_47 | AC | 1,234 ms
52,464 KB |
testcase_48 | AC | 1,165 ms
52,456 KB |
testcase_49 | AC | 1,354 ms
52,276 KB |
ソースコード
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; ++i) { a[i] = sc.nextInt(); } int[] member = new int[m]; int answer = 0; boolean[] isMember = new boolean[n]; for (int i = 0; i < m; ++i) { answer ^= a[i]; member[i] = i; isMember[i] = true; } for (int i = 0; i < 1e7; ++i) { int rnd1 = (int) (Math.random() * m); int rnd2 = (int) (Math.random() * n); if (isMember[rnd2]) continue; int tmp = answer ^ a[rnd2] ^ a[member[rnd1]]; if (tmp > answer) { isMember[member[rnd1]] = false; isMember[rnd2] = true; member[rnd1] = rnd2; answer = tmp; } } for (int i = 0; i < m; ++i) { System.out.print(a[member[i]] + (i == m - 1 ? "\n" : " ")); } } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }