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

One time

Time limit: 500 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers. Your task is to process $q$ queries of the form $(l,r)$, find a value occuring exactly one time in the subarray $A_l,A_{l+1},...,A_r$. ### Input - The first line contains two integers $n,q$. - The second line contains $n$ integer $A_i$. - The next $q$ lines, each line contains two integer $l,r$, a query. ### Output - For each query, print the value occuring exactly in the given subarray. If there are multiple value, print any. If there are no satisfied value, print `0`. ### Constraints - $1 \le n, q \le 2 \times 10^5$. - $1 \le A_i \le 2 \times 10^5$. - $1 \le l \le r \le n$. ### Example Input: ``` 6 2 1 1 2 3 2 4 2 6 1 2 ``` Output: ``` 4 0 ```
Introduction to Segment Tree and Binary Indexed Tree
Point update, sum query
Point update, minimum query
Range update, sum query
Range update, minimum query
Apple picking
Non-negative subarray
Inversions
K-query
Divisible by 3
Mushroom harvesting
KSS
D-query
Greatest subarray sum
Copying data
Within 1
Within 2
Ladder update
Racing
One time
Subarray XOR
String sorting
Odd query
Full sequence
Topic
Data structure
Rating 1800
Solution (1) Solution