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

28204번 - Classical Data Structure Problem 다국어

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

문제

You have an integer array $A = [a_0, a_1, \ldots, a_{2^m-1}]$ of length 2ドル^m$. Initially, the array consists of zeros.

You also have an integer variable $x$. Initially, $x = 0$.

For each $i = 1, 2, \ldots, n,ドル you are given two integers $p_i$ and $q_i,ドル and you have to perform the following steps:

  • Let $p' = (p_i + x) \bmod 2^m$ and $q' = (q_i + x) \bmod 2^m$.
  • Let $l = \min(p', q')$ and $r = \max(p', q')$.
  • For each $j = l, l+1, \ldots, r,ドル increase $a_j$ by $i,ドル then increase $x$ by $a_j$.

Find the value of $x \bmod 2^{30}$ at the end of this process.

입력

The first line contains two integers $n$ and $m$ (1ドル \le n \le 500,000円$; 1ドル \le m \le 30$).

The $i$-th of the following $n$ lines contains two integers $p_i$ and $q_i$ (0ドル \le p_i, q_i < 2^m$).

출력

Print the value of $x \bmod 2^{30}$.

제한

예제 입력 1

5 2
2 1
1 3
3 2
1 0
0 2

예제 출력 1

87

노트

In the example test, initially, $A = [0, 0, 0, 0]$ and $x = 0$. Then:

  • For $i = 1,ドル we have $l = 1$ and $r = 2$. Then, $A = [0, 1, 1, 0]$ and $x = 2$.
  • For $i = 2,ドル we have $l = 1$ and $r = 3$. Then, $A = [0, 3, 3, 2]$ and $x = 10$.
  • For $i = 3,ドル we have $l = 0$ and $r = 1$. Then, $A = [3, 6, 3, 2]$ and $x = 19$.
  • For $i = 4,ドル we have $l = 0$ and $r = 3$. Then, $A = [7, 10, 7, 6]$ and $x = 49$.
  • For $i = 5,ドル we have $l = 1$ and $r = 3$. Then, $A = [7, 15, 12, 11]$ and $x = 87$.

출처

Camp > Petrozavodsk Programming Camp > Winter 2023 > Day 7: Gennady Korotkevich Contest 7 C번

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

출처

대학교 대회

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

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