PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000133. XOR lớn nhất của đoạn con (Maximum Xor Subarray)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
XOR lớn nhất của đoạn con (Maximum Xor Subarray)
Maximum Xor Subarray
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Given nonnegative integers , the value of a nonempty contiguous interval is , where denotes bitwise XOR. Find the largest value over all intervals .
Input
First line: integer .
Second line: integers .
Output
Print one integer, the maximum interval XOR.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Example 1
Input
4
5 1 5 9
Output
13
Explanation
Interval has XOR . By length, the values are (5,1,5,9), (4,4,12), (1,13), and (8). Their maximum is 13.
Example 2
Input
1
0
Output
0
Explanation
The only interval contains one element, whose XOR is zero.