当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7035:Game

题目描述
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. When it comes to 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.

It is too boring for Koishi, so she comes up with the following 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)$, which means that when it comes to 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$. Moreover, if there is a special sub-segment $(x,x,1)$, then the player will immediately win when the remaining array is $[x,x]$ (In default case, when there is only one number, the player will lose).

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 subsegment $[a_i,b_i]$. 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 2 \times 10^3)$ - the number of test cases. Then $T$ test cases follow.

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

Then $n$ lines follow, each line contains $3$ integers $l_i, r_i, z_i(1\leq l_i\leq r_i\leq 10^9,0 \leq z_i \leq 1)$, satisfing that for any $i\neq j$, $(l_i,r_i)\neq (l_j,r_j)$ holds.

Then $q$ lines follow, each line contains $2$ integers $a_i, b_i(1\leq a_i\leq b_i\leq 10^9)$ - the initial sub-segment of the $i$-th game.

It is guaranteed that $\sum (n+q)\leq 9 \times 10^5$.
输出解释
For each test case, output one line with $q$ integers $v_i(0 \leq v_i \leq 1)$ without spaces, that $v_i = 0$ if Koishi will lose in the $i$-th game and $v_i = 1$ if she will win in the $i$-th game.
输入样例
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
输出样例
0010111101

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7035

最后修改于 2021-10-23T19:11:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/10000MS(Java/Others) 524288/524288K(Java/Others)