Problem Solving/백준

[21099] Four XOR

충무로술겜마 2021. 9. 11. 03:40

https://www.acmicpc.net/problem/21099

 

21099번: Four XOR

Given a sequence $A_{1...n}$ of distinct integers, you need to answer whether there exist four indices $x, y, z, w$ such that $1 \le x < y < z < w \le n$ and $A_x \oplus A_y \oplus A_z \oplus A_w = 0$. Recall that $x \oplus y$ means the bitwise exclusive-o

www.acmicpc.net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
= int(input())
if n > 60:
    print("Yes")
    exit()
else:
    input_list = list(map(int, input().split()))
    result = input_list[0]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                for m in range(n):
                    result = (input_list[i] ^ input_list[j] ^ input_list[k] ^ input_list[m])
                    if result == 0 and (input_list[i] < input_list[j] < input_list[k] < input_list[m]):
                        print("Yes")
                        exit()
print("No")
 
cs