Equalmex

시간 제한5초메모리 제한1024 MB

요약
각 질의 부분 배열마다, 부분 배열을 같은 최소 양의 미포함 정수를 갖는 k개의 연속 구간으로 나눌 수 있는 k의 개수를 구한다.
난이도

어려움10점 중 10점

유형
배열, 세그먼트 트리, 누적 합, 완전 탐색
정답자
아직 제출이 없습니다

문제

It is well known among Romanian noblemen that the beauty of an integer array a\[0],a\[1],a\[2],…,a\[m−1]a\[0], a\[1], a\[2],\dots , a\[m − 1] is the number of positive integers kk for which you can split the array into kk disjoint subarrays (sequences of consecutive elements) such that each element is contained in exactly one subarray and all the subarrays have the same minimum excluded element. The minimum excluded element of an integer array is the smallest strictly positive integer (greater than 00) that does not appear in the array.

You are given an integer array v\[0],v\[1],…,v\[n−1]v\[0], v\[1],\dots ,v\[n − 1] and qq queries of the form (l_i,r_i)(l\_i , r\_i ), where 0≤l_i≤r_i<n0 ≤ l\_i ≤ r\_i < n for all 0≤i<q0 ≤ i < q.

For each query, you have to find the beauty of the array v\[l_i],v\[l_i+1],…,v\[r_i]v\[l\_i ], v\[l\_i + 1], \dots , v\[r\_i ].

제한

  • 1≤n≤600,0001 ≤ n ≤ 600\\, 000
  • 1≤q≤600,0001 ≤ q ≤ 600\\, 000
  • 1≤v\[i]≤400,0001 ≤ v\[i] ≤ 400\\, 000 for all 0≤i<n0 ≤ i < n
  • 0≤l_i≤r_i<n0 ≤ l\_i ≤ r\_i < n for all 0≤i<q0 ≤ i < q

예제

이 문제는 공개된 예제가 없습니다.