CF1000F.One Occurrence
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a consisting of n integers, and q queries to it. i -th query is denoted by two integers li and ri . For each query, you have to find any integer that occurs exactly once in the subarray of a from index li to index ri (a subarray is a contiguous subsegment of an array). For example, if a=[1,1,2,3,2,4] , then for query (li=2,ri=6) the subarray we are interested in is [1,2,3,2,4] , and possible answers are 1 , 3 and 4 ; for query (li=1,ri=2) the subarray we are interested in is [1,1] , and there is no such element that occurs exactly once.
Can you answer all of the queries?
输入格式
The first line contains one integer n ( 1≤n≤5⋅105 ).
The second line contains n integers a1,a2,…,an ( 1≤ai≤5⋅105 ).
The third line contains one integer q ( 1≤q≤5⋅105 ).
Then q lines follow, i -th line containing two integers li and ri representing i -th query ( 1≤li≤ri≤n ).
输出格式
Answer the queries as follows:
If there is no integer such that it occurs in the subarray from index li to index ri exactly once, print 0 . Otherwise print any such integer.
输入输出样例
输入#1
6 1 1 2 3 2 4 2 2 6 1 2
输出#1
4 0