Guest User

Untitled

a guest
Feb 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Input
  2.  
  3. Line 1: n (1 ≤ n ≤ 10^6).
  4. Line 2: n numbers a1, a2, ..., an (-10^9 ≤ ai ≤ ).
  5. Line 3: q (1 ≤ q ≤ 10^6), the number of d-queries.
  6. In the next q lines, each line contains 2 numbers i, j
  7. representing a d-query (1 ≤ i ≤ j ≤ n).
  8.  
  9. Output
  10.  
  11. For each d-query (i, j), print the number of distinct elements in the
  12. subsequence ai, ai+1, ..., aj in a single line.
  13. Example
  14.  
  15. Input
  16. 9
  17. 1 2 3 2 4 1 2 3 4
  18. 3
  19. 1 9
  20. 2 4
  21. 5 9
  22. 2 7
  23.  
  24. Output
  25. 0 //Explanation: all elements have been repeated.
  26. 1 //Explanation: only 3 has not repeated.
  27. 3 //Explanation: only 4 is repeated, so count only 1, 2 and 3.
  28. 3 //Explanation: only 2 is repeated, so count only 3, 4 and 1.
Add Comment
Please, Sign In to add comment