Pinely Round 4 (Div. 1 + Div. 2)
E
Coloring Game
Codeforces
1900
原题
← DF →
翻译中…

This is an interactive problem.

翻译中…

Consider an undirected connected graph consisting of $n$ vertices and $m$ edges. Each vertex can be colored with one of three colors: $1$, $2$, or $3$. Initially, all vertices are uncolored.

翻译中…

Alice and Bob are playing a game consisting of $n$ rounds. In each round, the following two-step process happens:

翻译中…
  1. Alice chooses two different colors.
  2. Bob chooses an uncolored vertex and colors it with one of the two colors chosen by Alice.
翻译中…

Alice wins if there exists an edge connecting two vertices of the same color. Otherwise, Bob wins.

翻译中…

You are given the graph. Your task is to decide which player you wish to play as and win the game.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases. The description of test cases follows.

翻译中…

The first line of each test case contains two integers $n$, $m$ ($1 \le n \le 10^4$, $n - 1 \le m \le \min(\frac{n \cdot (n - 1)}{2}, 10^4)$) — the number of vertices and the number of edges in the graph, respectively.

翻译中…

Each of the next $m$ lines of each test case contains two integers $u_i$, $v_i$ ($1 \le u_i, v_i \le n$) — the edges of the graph. It is guaranteed that the graph is connected and there are no multiple edges or self-loops.

翻译中…

It is guaranteed that the sum of $n$ and the sum of $m$ over all test cases does not exceed $10^4$.

翻译中…

Interaction

翻译中…

For each test case, you need to output a single line containing either "Alice" or "Bob", representing the player you choose.

翻译中…

Then for each of the following $n$ rounds, the following two-step process happens:

翻译中…
  1. Alice (either you or the interactor) will output two integers $a$ and $b$ ($1 \le a, b \le 3$, $a \neq b$) — the colors chosen by Alice.
  2. Bob (either you or the interactor) will output two integers $i$ and $c$ ($1 \le i \le n$, $c = a$ or $c = b$) — the vertex and the color chosen by Bob. Vertex $i$ must be a previously uncolored vertex.
翻译中…

If any of your outputs are invalid, the jury will output "-1" and you will receive a Wrong Answer verdict.

翻译中…

At the end of all $n$ turns, if you have lost the game, the jury will output "-1" and you will receive a Wrong Answer verdict.

翻译中…

If your program has received a $-1$ instead of a valid value, it must terminate immediately. Otherwise, you may receive an arbitrary verdict because your solution might be reading from a closed stream.

翻译中…

Note that if you are playing as Alice, and there already exists an edge connected two vertices of the same color, the interactor will not terminate early and you will keep playing all $n$ rounds.

翻译中…

After outputting, do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

翻译中…
  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • see documentation for other languages.
翻译中…

In this problem, hacks are disabled.

翻译中…

Note

翻译中…

Note that the sample test cases are example games and do not necessarily represent the optimal strategy for both players.

翻译中…

In the first test case, you choose to play as Alice.

翻译中…
  1. Alice chooses two colors: $3$ and $1$. Bob chooses vertex $3$ and colors it with color $1$.
  2. Alice chooses two colors: $1$ and $2$. Bob chooses vertex $2$ and colors it with color $2$.
  3. Alice chooses two colors: $2$ and $1$. Bob chooses vertex $1$ and colors it with color $1$.
翻译中…

Alice wins because the edge $(3, 1)$ connects two vertices of the same color.

翻译中…

In the second test case, you choose to play as Bob.

翻译中…
  1. Alice chooses two colors: $2$ and $3$. Bob chooses vertex $1$ and colors it with color $2$.
  2. Alice chooses two colors: $1$ and $2$. Bob chooses vertex $2$ and colors it with color $1$.
  3. Alice chooses two colors: $2$ and $1$. Bob chooses vertex $4$ and colors it with color $1$.
  4. Alice chooses two colors: $3$ and $1$. Bob chooses vertex $3$ and colors it with color $3$.
翻译中…

Bob wins because there are no edges with vertices of the same color.

翻译中…

样例

Input #1
2
3 3
1 2
2 3
3 1

3 1

2 2

1 1
4 4
1 2
2 3
3 4
4 1

2 3

1 2

2 1

3 1
Output #1
Alice
3 1

1 2

2 1

Bob

1 2

2 1

4 1

3 3
InputCopy OutputCopy
题目信息
题号
1991E
时间限制
2 s
内存限制
256 MB
标签
构造
DFS 及类似
博弈论
图论
贪心
交互题

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。