Logo
(追記) (追記ここまで)

31083번 - Prof. Pang's sequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB443100.000%

문제

Prof. Pang is given a fixed sequence $a_1, \ldots, a_n$ and $m$ queries.

Each query is specified by two integers $l$ and $r$ satisfying 1ドル\le l\le r\le n$. For each query, you should answer the number of pairs of integers $(i, j)$ such that $l\le i\le j\le r$ and the number of distinct integers in $a_i, \ldots, a_j$ is odd.

입력

The first line contains a single integer $n$ (1ドル\le n\le 5\times 10^5$).

The next line contains $n$ integers $a_1, \ldots, a_n$ (1ドル\le a_i\le n$ for all 1ドル\le i\le n$) separated by single spaces.

The next line contains a single integer $m$ (1ドル\le m\le 5\times 10^5$).

Each of the next $m$ lines contains two integers $l$ and $r$ (1ドル\le l\le r\le n$) separated by a single space denoting a query.

출력

For each query, output one line containing the answer to that query.

제한

예제 입력 1

5
1 2 3 2 1
5
1 5
2 4
1 3
2 5
4 4

예제 출력 1

10
3
4
6
1

예제 입력 2

5
2 3 5 1 5
5
2 3
1 1
1 3
2 5
2 4

예제 출력 2

2
1
4
6
4

예제 입력 3

10
2 8 5 1 10 5 9 9 3 5
10
6 8
1 2
3 5
5 7
1 7
3 9
4 9
1 4
3 7
2 5

예제 출력 3

4
2
4
4
16
16
12
6
9
6

힌트

출처

Contest > Open Cup > 2020/2021 Season > Stage 15, Grand Prix of China, Division 1 G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /