QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 63 MB Total points: 100

#11268. Yuno loves sqrt technology III

Statistics

You are given a sequence $a$ of length $n$ and $m$ queries. Each query asks for the frequency of the mode (the most frequent element) in a given range. The queries are provided online.

Input

The first line contains two integers $n$ and $m$.

The second line contains $n$ integers representing the sequence.

The following $m$ lines each contain two integers representing the query range.

This problem requires online processing. For each query, the input values must be XORed with $lastans$. For the first query, $lastans = 0$.

Output

Output $m$ lines, each containing a single integer representing the answer to the corresponding query.

Examples

Input 1

4 1
2 3 3 3
2 4

Output 1

3

Subtasks

$1 \leq n, m, a_i \leq 5 \times 10^5$.

An $O(n^{1.48541})$ algorithm exists.

By nzhtl1477

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.