report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Mode - FlandreOJ: Flandre Online Judge

Mode

Time limit: 1000 ms
Memory limit: 256 MB
Given an integer sequence $A$ and $q$ queries in the form of $l, r$, find the number of occurrences of the most frequent value in the range $A_l, A_{l+1}, ..., A_r$. ### Input - The first line consists of two integers $n, q$. - The second line contains $n$ integers $A_i$. - The next $q$ lines each contain two integers $x, y$, representing a query. Two integers $l, r$ are calculated as follows: + $l = (x + \text{lastans}) \mod n + 1$ + $r = (y + \text{lastans}) \mod n + 1$ + $\text{lastans}$ is the answer from the previous query. In the first query, $\text{lastans}$ is conventionally set to $0$. If $l > r$, swap the values of $l$ and $r$. ### Output - Print $q$ lines, each line containing the corresponding answer for each query. ### Constraints - $1 \le n, q \le 2 \times 10^5$. - $1 \le A_i \le 2 \times 10^5$. - $1 \le x,y \le n$. ### Sample Input: ``` 5 3 1 2 2 3 2 1 3 1 5 4 5 ``` Output: ``` 2 1 1 ```
Square root decomposition
Frequency
Tree query
Inversions query
Nearest vertex
Dominating color
String occurences 3
Inversions query 2
Pair
Sparse update
Tree
Range query
String concatenation
Subarray distance
Chameleon
Knapsack
Bit counting
Subsequence queries
Sub-subsequence
Delete numbers
Mode
Marisa is happy
Inversions query 3
Upperbound
23 path
Yet another square root decomposition problem
Marisa plays poker
Wonderful world
Topic
Data structure
Rating 2200
Solution (1) Solution