QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 512 MB 總分: 100

#7440. rsxc

统计

Given a sequence of non-negative integers $a_0, a_1, \dots, a_{n-1}$ of length $n$ ($1 \le n \le 6 \times 10^5$), where $0 \le a_i < 2^{30}$.

There are $q$ queries ($1 \le q \le 10^6$).

For each query, you are given two integers $l$ and $r$ ($0 \le l \le r < n$). Find the number of pairs of integers $(x, y)$ such that:

  • $l \le x \le y \le r$;
  • $\forall i, j \in S : i \oplus j \in S$, where $S := \{a_k\}_{k=x}^y$.

Implementation Details

Due to the large amount of data, you do not need to handle input and output. Please complete the init(int, int, vector<int>) and solve(int, int) functions in the following program and submit it.

void init(int n, int q, vector<int> a) {
  // implement...
}

long long solve(int l, int r) {
  // implement...
}

You can obtain the sample interaction library in the provided files.

Examples

Input 1

5 10 2
0000000001000020000300004

Output 1

4834712607666044912

Input 2

20 100 16500242824326557842
0000500006000070000800000000010000200003000040000000001000020000300004000090000:0000;0000<0000=0000>

Output 2

5449866856465492064

Subtasks

Idea: Powerless, Solution: ccz181078 & noip & w33z, Code: w33z, Data: w33z

For $100\%$ of the data, $1 \le n \le 6 \times 10^5$, $1 \le q \le 10^6$, $0 \le a_i < 2^{30}$, and $0 \le l \le r < n$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.