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

23157번 - Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 512 MB173350.000%

문제

Koishi is playing a game with Satori.

There is an array of length 10ドル^{18}$. In the game, Koishi and Satori take turns operating on this array, and Koishi goes first. At the start of a player's turn, if there is only one element left in the array, she loses the game immediately. Otherwise, she needs to delete either the leftmost number or the rightmost number of the remaining array.

The game is too boring for Koishi, so she came up with the following modified rules.

There are $n$ sub-segments of this array that are special. Specifically, the $i$-th sub-segment is described by three integers $(l_i, r_i, z_i)$. They mean that, at the start of a player's turn, if the remaining array is the sub-segment $[l_i, r_i],ドル she will win immediately if $z_i = 1$ or lose immediately if $z_i = 0$.

If there is a special sub-segment $(x, x, 1)$ given for some $x,ドル a player will immediately win when the remaining array is $[x, x]$ at the start of their turn. Importantly, if there is no special sub-segment $(x, x, 1)$ given for some $x,ドル it is assumed that $[x, x]$ is an immediate loss, as in the original rules.

There will be $q$ games. At the beginning of the $i$-th game, Utuoho will give two players the sub-segment $[a_i, b_i]$ and take away all other parts of the array. That means Koishi and Satori only play on sub-segment $[a_i, b_i],ドル not on the whole array. All the $q$ games are independent.

Two players always use the optimal strategy. Please tell them who will win in each game.

입력

The first line contains an integer $T$ (1ドル \leq T \leq 2000$), the number of test cases. Then $T$ test cases follow.

The first line of each test case contains two integers $n$ and $q$ (1ドル \leq n, q \leq 10^5$), the number of sub-segments and the number of games.

Then $n$ lines follow. Each of them contains three integers: $l_i,ドル $r_i,ドル $z_i$ (1ドル \leq l_i \leq r_i \leq 10^9,ドル 0ドル \leq z_i \leq 1$). You may assume that, for any $i \neq j,ドル $(l_i, r_i) \neq (l_j, r_j)$ holds.

After that, $q$ lines follow. Each of them contains two integers $a_i$ and $b_i$ (1ドル \leq a_i \leq b_i \leq 10^9$) describing the initial sub-segment of the $i$-th game.

It is guaranteed that $\sum (n + q) \leq 9 \cdot 10^5$.

출력

For each test case, output one line with $q$ integers $v_i$ (0ドル \leq v_i \leq 1$) without spaces: $v_i = 0$ if Koishi loses the $i$-th game and $v_i = 1$ if she wins the $i$-th game, respectively.

제한

예제 입력 1

1
5 10
1 2 0
3 3 1
3 4 1
2 4 1
1 3 0
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

예제 출력 1

0010111101

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 6: Xi’an JTU Contest 1, GP of Xi’an J번

Contest > Open Cup > 2021/2022 Season > Stage 3: Grand Prix of XiAn J번

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

출처

대학교 대회

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

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