File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ ```
2+ import java.io.*;
3+ import java.util.*;
4+
5+ public class Main {
6+ private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+ private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+ private static TreeSet<Integer>[] dp;
9+ private static int[] arr;
10+ private static int N, M;
11+
12+ public static void main(String[] args) throws IOException {
13+ init();
14+ DP();
15+
16+ bw.write(dp[M].last() + "\n");
17+
18+ bw.flush();
19+ bw.close();
20+ br.close();
21+ }
22+
23+ private static void init() throws IOException {
24+ StringTokenizer st = new StringTokenizer(br.readLine());
25+ N = Integer.parseInt(st.nextToken());
26+ M = Integer.parseInt(st.nextToken());
27+
28+ arr = new int[N + 1];
29+ dp = new TreeSet[M + 1];
30+
31+ for (int i = 0; i <= M; i++) {
32+ dp[i] = new TreeSet<>();
33+ }
34+
35+ st = new StringTokenizer(br.readLine());
36+ for (int i = 1; i <= N; i++) {
37+ arr[i] = Math.abs(Integer.parseInt(st.nextToken()));
38+ }
39+ }
40+
41+ private static void DP() {
42+ dp[0].add(0);
43+ for (int i = 1; i <= M; i++) {
44+ for (int j = 1; j <= N; j++) {
45+ for (int val : dp[i - 1]) {
46+ dp[i].add(arr[j] ^ val);
47+ }
48+ }
49+ }
50+ }
51+ }
52+
53+ ```
You can’t perform that action at this time.
0 commit comments