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

25655번 - Great Party 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB306631.579%

문제

Grammy joined a great party.

There is an interesting game at the party. There are $n$ piles of stones on the table. The $i$-th pile has $a_i$ stones in it. Two players participate in the game and operate the stones in turn.

In each player's turn, the player will do the following two steps:

  1. Select a non-empty pile of stones, select a positive amount of stones to remove from it.
  2. Keep the remaining stones in the pile still or merge them all into another non-empty pile of stones.

Those who cannot operate lose the game.

Now, Grammy has $q$ questions. For each question, she asks you how many sub-segments of $[l,r]$ satisfy that if the piles in the segment are taken out alone for the game, the first player will win.

입력

The first line contains two integers $n$ and $q$ (1ドル \leq n, q \leq 10^5$).

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ (1ドル \leq a_i \leq 10^6$).

The $i$-th of the next $q$ lines contains two integers $l_i$ and $r_i$ (1ドル \leq l_i \leq r_i \leq n$).

출력

The output contains $q$ lines. Each line contains a single integer, denoting the answer to the question.

제한

예제 입력 1

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

예제 출력 1

3
2
3
5
5

예제 입력 2

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

예제 출력 2

3
3
3
6
6

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2022 > Day 2: ZJU Contest 1 K번

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

출처

대학교 대회

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

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