diff --git "a/Ukj0ng/202508/27 BOJ G3 \353\271\204\355\212\270\354\275\224\354\235\270\354\235\200 \354\213\240\354\235\264\352\263\240 \353\202\230\353\212\224 \353\254\264\354\240\201\354\235\264\353\213\244.md" "b/Ukj0ng/202508/27 BOJ G3 \353\271\204\355\212\270\354\275\224\354\235\270\354\235\200 \354\213\240\354\235\264\352\263\240 \353\202\230\353\212\224 \353\254\264\354\240\201\354\235\264\353\213\244.md" new file mode 100644 index 00000000..4354cc4a --- /dev/null +++ "b/Ukj0ng/202508/27 BOJ G3 \353\271\204\355\212\270\354\275\224\354\235\270\354\235\200 \354\213\240\354\235\264\352\263\240 \353\202\230\353\212\224 \353\254\264\354\240\201\354\235\264\353\213\244.md" @@ -0,0 +1,53 @@ +``` +import java.io.*; +import java.util.*; + +public class Main { + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + private static TreeSet[] dp; + private static int[] arr; + private static int N, M; + + public static void main(String[] args) throws IOException { + init(); + DP(); + + bw.write(dp[M].last() + "\n"); + + bw.flush(); + bw.close(); + br.close(); + } + + private static void init() throws IOException { + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + arr = new int[N + 1]; + dp = new TreeSet[M + 1]; + + for (int i = 0; i <= M; i++) { + dp[i] = new TreeSet<>(); + } + + st = new StringTokenizer(br.readLine()); + for (int i = 1; i <= N; i++) { + arr[i] = Math.abs(Integer.parseInt(st.nextToken())); + } + } + + private static void DP() { + dp[0].add(0); + for (int i = 1; i <= M; i++) { + for (int j = 1; j <= N; j++) { + for (int val : dp[i - 1]) { + dp[i].add(arr[j] ^ val); + } + } + } + } +} + +```