CF1823E.Removing Graph
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Alice and Bob are playing a game on a graph. They have an undirected graph without self-loops and multiple edges. All vertices of the graph have degree equal to 2. The graph may consist of several components. Note that if such graph has n vertices, it will have exactly n edges.
Alice and Bob take turn. Alice goes first. In each turn, the player can choose k (l≤k≤r; l<r) vertices that form a connected subgraph and erase these vertices from the graph, including all incident edges.
The player who can't make a step loses.
For example, suppose they are playing on the given graph with given l=2 and r=3:

A valid vertex set for Alice to choose at the first move is one of the following:
- 1,2
- 1,3
- 2,3
- 4,5
- 4,6
- 5,6
- 1,2,3
- 4,5,6
Suppose, Alice chooses subgraph 4,6.
Then a valid vertex set for Bob to choose at the first move is one of the following:
- 1,2
- 1,3
- 2,3
- 1,2,3
Suppose, Bob chooses subgraph 1,2,3.
Alice can't make a move, so she loses.
You are given a graph of size n and integers l and r. Who will win if both Alice and Bob play optimally.
爱丽丝和鲍勃正在一张图上进行一场游戏。他们拥有一张无向图,该图不含自环和重边。图中所有顶点的度数均为 2。该图可能由若干个连通分量组成。注意:若这样的图有 n 个顶点,则它恰好有 n 条边。
爱丽丝和鲍勃轮流进行操作,爱丽丝先行。在每一轮中,当前玩家可以选择 k(其中 l≤k≤r;且 l<r)个顶点,这些顶点需构成一个连通子图,并将这些顶点及其所有关联边从图中删除。
无法进行操作的玩家判负。
例如,假设他们在如下图所示的图上进行游戏,且给定 l=2、r=3:

爱丽丝在第一步中可选择的合法顶点集为以下之一:
- 1,2
- 1,3
- 2,3
- 4,5
- 4,6
- 5,6
- 1,2,3
- 4,5,6
假设爱丽丝选择了子图 4,6。
则鲍勃在第一步中可选择的合法顶点集为以下之一:
- 1,2
- 1,3
- 2,3
- 1,2,3
假设鲍勃选择了子图 1,2,3。
此时爱丽丝无法再进行任何操作,因此她输掉游戏。
现给定一张大小为 n 的图,以及整数 l 和 r。若爱丽丝与鲍勃均采取最优策略,谁将获胜?
输入格式
The first line contains three integers n, l and r (3≤n≤2⋅105; 1≤l<r≤n) — the number of vertices in the graph, and the constraints on the number of vertices Alice or Bob can choose in one move.
Next n lines contains edges of the graph: one edge per line. The i-th line contains two integers ui and vi (1≤ui,vi≤n; ui=vi) — description of the i-th edge.
It's guaranteed that the degree of each vertex of the given graph is equal to 2.
第一行包含三个整数 n、l 和 r(3≤n≤2⋅105;1≤l<r≤n)—— 分别表示图中顶点的数量,以及 Alice 或 Bob 每次操作可选择的顶点数的约束范围。
接下来 n 行描述图中的边:每行一条边。第 i 行包含两个整数 ui 和 vi(1≤ui,vi≤n;ui=vi)—— 表示第 i 条边。
保证所给图中每个顶点的度数均为 2。
输出格式
Print Alice (case-insensitive) if Alice wins, or Bob otherwise.
如果 Alice 获胜(不区分大小写),则输出 Alice;否则输出 Bob。
输入输出样例
输入#1
6 2 3 1 2 2 3 3 1 4 5 5 6 6 4
输出#1
Bob
输入#2
6 1 2 1 2 2 3 3 1 4 5 5 6 6 4
输出#2
Bob
输入#3
12 1 3 1 2 2 3 3 1 4 5 5 6 6 7 7 4 8 9 9 10 10 11 11 12 12 8
输出#3
Alice
说明/提示
In the first test the same input as in legend is shown.
In the second test the same graph as in legend is shown, but with l=1 and r=2.
第一个测试用例展示了图例中的相同输入。
第二个测试用例展示了图例中的相同图,但其中 l=1 且 r=2。
输入解题思路,AI测评打分。不知道怎么写?