CF2180H2.Bug Is Feature (Conditional Version)

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is the conditional version of the problem. The difference between the versions is that in this version, the "non-decreasing common difference" is present. You can hack only if you solved all versions of this problem.

Note that neither version is necessarily easier than the other, and they can be solved independently.

Bug and Feature are immersed in a game of Sequence. In this unique version of the Sequence game, a sequence begins with three positive integers a<b<c≤xa \lt b \lt c \le x, forming an arithmetic progression (i.e., b−a=c−bb-a=c-b). During each turn, a player can selectively increase one of aa, bb, or cc by a positive integer. After the move, the numbers must retain their arithmetic progression, possibly with a new order, and a common difference not less than the previous one. Moreover, none of aa, bb, or cc should exceed xx.

Not content with the conventional Sequence game, Bug and Feature decide to engage in a nn series of Sequence games simultaneously. For the ii-th series, they are provided with five numbers ai<bi<ci≤li≤ria_i \lt b_i \lt c_i \le l_i \le r_i. They will play a game with numbers ai<bi<ci≤xa_i \lt b_i \lt c_i \le x for every integer xx in the range [li,ri][l_i, r_i] (resulting in a total of ∑i=1n(ri−li+1)\sum_{i=1}^n (r_i - l_i + 1) games). Taking turns, they play all the games together, with Bug starting first and then Feature. In each turn, a player selects an unfinished game and makes a move in that game. The player who cannot make a move loses.

Now, the question is: if both players play optimally, who will emerge victorious?

这是该问题的条件版本。两个版本的区别在于,本版本中存在“非递减的公差”。仅当您解决了该问题的所有版本后,才可进行 Hack。

请注意,两个版本的难度并不一定谁更简单,且可以独立求解。

Bug 和 Feature 正在玩一款名为“序列(Sequence)”的游戏。在这个独特的 Sequence 游戏版本中,一个序列由三个正整数 a<b<c≤xa \lt b \lt c \le x 开始,构成一个等差数列(即满足 b−a=c−bb-a=c-b)。在每一轮中,玩家可以选择将 aa、bb 或 cc 中的某一个数增加一个正整数。移动之后,这三个数必须仍构成一个等差数列(顺序可能改变),且其公差不小于上一轮的公差;此外,aa、bb、cc 中任意一个数均不可超过 xx。

Bug 和 Feature 不满足于常规的 Sequence 游戏,决定同时进行 nn 场 Sequence 游戏。对于第 ii 场游戏,他们获得五个数:ai<bi<ci≤li≤ria_i \lt b_i \lt c_i \le l_i \le r_i。他们将对区间 [li,ri][l_i, r_i] 内的每一个整数 xx,分别以 ai<bi<ci≤xa_i \lt b_i \lt c_i \le x 为初始状态进行一局游戏(总共进行 ∑i=1n(ri−li+1)\sum_{i=1}^n (r_i - l_i + 1) 局游戏)。所有游戏同步进行,双方轮流行动,Bug 先手,随后是 Feature。在每一回合中,当前玩家需选择一个尚未结束的游戏,并在其中执行一次合法移动。无法进行任何合法移动的玩家判负。

现在的问题是:若双方均采取最优策略,谁将获胜?

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1051 \le t \le 10^5). The description of the test cases follows.

The first line of each test case consists of a single integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the number of series of games that Bug and Feature wish to play.

Each of the next nn lines contains five integers ai,bi,ci,li,ria_i, b_i, c_i, l_i, r_i — (1≤ai<bi<ci≤li≤ri≤10181 \le a_i \lt b_i \lt c_i \le l_i \le r_i \le 10^{18}), representing the specifications of the ii-th series of games. aia_i, bib_i, and cic_i form an arithmetic progression. (ci−bi=bi−ai)(c_i-b_i=b_i-a_i)

The sum of nn over all test cases is at most 2⋅1052 \cdot 10^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1051 \le t \le 10^5)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)—— 表示 Bug 和 Feature 希望进行的游戏系列数量。

接下来的 nn 行中,每行包含五个整数 ai,bi,ci,li,ria_i, b_i, c_i, l_i, r_i(满足 1≤ai<bi<ci≤li≤ri≤10181 \le a_i \lt b_i \lt c_i \le l_i \le r_i \le 10^{18}),表示第 ii 个游戏系列的参数。其中 aia_i、bib_i 和 cic_i 构成一个等差数列(即 ci−bi=bi−aic_i - b_i = b_i - a_i)。

所有测试用例中 nn 的总和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test, output Bug\mathtt{Bug} if Bug wins, and Feature\mathtt{Feature} if Feature wins.

对于每组测试,如果 Bug 获胜,则输出 Bug\mathtt{Bug};如果 Feature 获胜,则输出 Feature\mathtt{Feature}。

输入输出样例

  • 输入#1

    5
    1
    1 3 5 5 6
    1
    2 4 6 8 10
    2
    4 6 8 10 11
    4 8 12 16 19
    1
    1 2 3 3 3
    1
    1000000000000 2000000000000 3000000000000 4000000000000 5000000000000

    输出#1

    Feature
    Bug
    Feature
    Feature
    Bug

说明/提示

In the first test case, no valid move is possible at the beginning of the game. Therefore, Bug cannot perform any action, and Feature wins immediately.

In the second test case, there are 33 instances of the game, corresponding to each value of xx in the range 88 to 1010. The sequence in each instance is initially 2,  4,  62,\;4,\;6.

Bug can secure a winning strategy as follows:

  1. In the instance with x=10x = 10, Bug changes bb from 44 to 1010. As a result, the sequence becomes 2,  6,  102,\;6,\;10, and it is easy to verify that no further move is possible in this instance.

  2. Next, Feature must play by changing the value aa from 22 to 88 in one of the remaining two instances (either the game with x=8x = 8 or x=9x = 9).

  3. Regardless of Feature's choice, Bug responds by changing the value aa to 88 in the other instance. After this move, the sequence in that instance also becomes fixed, and no further operation can be performed.

Thus, after these moves, all three instances reach states where no player can make any additional move, ensuring Bug's victory.

在第一个测试用例中,游戏开始时不存在任何合法操作。因此,Bug 无法执行任何动作,Feature 立即获胜。

在第二个测试用例中,共有 33 个游戏实例,分别对应 xx 在区间 88 到 1010 内的每个取值。每个实例的初始序列为 2,  4,  62,\;4,\;6。

Bug 可以采用如下策略确保获胜:

  1. 在 x=10x = 10 的实例中,Bug 将 bb 从 44 改为 1010。结果序列变为 2,  6,  102,\;6,\;10,容易验证该实例中已无法进行任何进一步操作。

  2. 接着,Feature 必须在剩余两个实例(即 x=8x = 8 或 x=9x = 9 的游戏)中的某一个里,将 aa 从 22 改为 88。

  3. 无论 Feature 选择哪一个实例,Bug 都在另一个实例中将 aa 改为 88。完成此操作后,该实例的序列也达到稳定状态,无法再进行任何操作。

因此,经过上述操作后,全部三个实例均进入无法继续操作的状态,从而保证 Bug 获胜。

输入解题思路,AI测评打分。不知道怎么写?

首页