PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000129. Yurii có thể làm mọi thứ (Yurii Can Do Everything)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Yurii có thể làm mọi thứ (Yurii Can Do Everything)
Yurii Can Do Everything
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array of positive integers, call a contiguous subarray good if it contains at least three elements and
The symbol denotes bitwise XOR. Count all good subarrays, distinguishing subarrays by their endpoints.
Input
- The first line contains .
- The second line contains .
Output
Print the number of good subarrays.
Subtasks
- Subtask 1 (10 points): , .
- Subtask 2 (20 points): , .
- Subtask 3 (30 points): , .
- Subtask 4 (40 points): , (original full constraints).
Examples
Example 1
Input
8
3 1 2 3 1 2 3 15
Output
6
Explanation: The subarrays and each appear twice and satisfy the equality; appears once; and the whole array also satisfies it because equals the sum of its six interior elements.
Example 2
Input
10
997230370 58052053 240970544 715275815 250707702 156801523 44100666 64791577 43523002 480196854
Output
2
Explanation: Exactly two 1-indexed endpoint pairs work: with interior sum , and with interior sum . In each case the XOR of the two endpoints equals that sum.