A13423 | Nastya and Bees
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Surely you all read the book "Alice in Wonderland". In this task, Nastya got to the country of Three strange Bees. The bees are strange because their honeycombs are pentagonal. Nastya got there illegally, so she wants bees not to catch her. Help the bees punish the intruder!
This is an interactive problem.
A beehive is a connected undirected graph where bees and Nastya can move along the edges. A graph satisfies two properties:
- The degree of any of its vertex is no more than $3$ .
- For each edge, there exists a cycle of length not greater than $5$ passing through this edge.
There are three bees and Nastya. You play for bees. Firstly, you choose the vertices where you put the bees. Then Nastya chooses another vertex in which she will initially appear. One move is first moving the bees, then Nastya, in turn: 1. For each of your bees, you can either move each one along some edge from the vertex they are currently staying or leave it in place.
2. Then Nastya will necessarily move along some edge of the graph from the vertex she is currently staying/.
You win if at least one of the bees and Nastya are in the same vertex at any time of the game.
If this situation does not occur after $n$ moves, then you lose.
Several bees can be in the same vertex.
This is an interactive problem.
A beehive is a connected undirected graph where bees and Nastya can move along the edges. A graph satisfies two properties:
- The degree of any of its vertex is no more than $3$ .
- For each edge, there exists a cycle of length not greater than $5$ passing through this edge.
There are three bees and Nastya. You play for bees. Firstly, you choose the vertices where you put the bees. Then Nastya chooses another vertex in which she will initially appear. One move is first moving the bees, then Nastya, in turn: 1. For each of your bees, you can either move each one along some edge from the vertex they are currently staying or leave it in place.
2. Then Nastya will necessarily move along some edge of the graph from the vertex she is currently staying/.
You win if at least one of the bees and Nastya are in the same vertex at any time of the game.
If this situation does not occur after $n$ moves, then you lose.
Several bees can be in the same vertex.
输入格式
The first line contains two integers $n$ $(4 \leq n \leq 5000)$ and $m$ $(n \leq m \leq 3n)$ — the number of vertices and edges in the graph.
Each of the next $m$ lines contains two integers $v$ and $u$ $(1 \leq v, u \leq n)$ , which mean that there is an edge between the vertices $v$ and $u$ . It is guaranteed that the graph is connected, does not contain loops that the degree of any vertex does not exceed $3$ and a cycle of length no more than $5$ passes through each edge. Note that the graph may contain multiple edges.
Each of the next $m$ lines contains two integers $v$ and $u$ $(1 \leq v, u \leq n)$ , which mean that there is an edge between the vertices $v$ and $u$ . It is guaranteed that the graph is connected, does not contain loops that the degree of any vertex does not exceed $3$ and a cycle of length no more than $5$ passes through each edge. Note that the graph may contain multiple edges.
输出格式
At each turn, you must output exactly three vertices $a, b, c$ $(1 \leq a, b, c \leq n)$ . For the first time, $3$ vertices displayed will indicate which vertices you originally placed bees on. In response, you will receive the vertex where the jury placed Nastya. Each next $3$ vertices will indicate where the $3$ bees move at your turn. Each of the bees can, regardless of other bees, both remain at the current vertex and move along the edge. After the next output of $3$ vertices, in response, you get the number of the new vertex to which Nastya went.
As soon as one of the bees is at the same vertex with Nastya or you have reached the limit on the number of moves, your program should stop working. That is if you made a move, and one of the bees ended up at the same vertex with Nastya, your program must stop working, or if Nastya made a move and ended up at the same vertex with one of the bees, you should not make your move and the program should stop working.
If the number of moves exceeds limit ( $n$ , where $n$ is the number of vertices), you will get the Wrong Answer verdict.
Your solution may receive the verdict Idleness Limit Exceeded if you don't output anything or forget to flush the output buffer.
To flush the output buffer, you need to do the following immediately after printing the query and the line end:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- for other languages see documentation.
In this problem interactor is adaptive. This means that depending on all your previous moves, Nastya's behavior may change.
Hacks are not available for this problem.
As soon as one of the bees is at the same vertex with Nastya or you have reached the limit on the number of moves, your program should stop working. That is if you made a move, and one of the bees ended up at the same vertex with Nastya, your program must stop working, or if Nastya made a move and ended up at the same vertex with one of the bees, you should not make your move and the program should stop working.
If the number of moves exceeds limit ( $n$ , where $n$ is the number of vertices), you will get the Wrong Answer verdict.
Your solution may receive the verdict Idleness Limit Exceeded if you don't output anything or forget to flush the output buffer.
To flush the output buffer, you need to do the following immediately after printing the query and the line end:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- for other languages see documentation.
In this problem interactor is adaptive. This means that depending on all your previous moves, Nastya's behavior may change.
Hacks are not available for this problem.
输入输出样例
输入 #1
5 5 1 2 2 3 3 4 4 5 5 1 4 5
输出 #1
1 1 2 1 5 3
输入 #2
8 9 1 2 2 3 3 4 4 5 5 1 5 6 6 7 7 8 8 4 1 5
输出 #2
7 3 3 6 2 2 5 3 1
Let Nastya be a green chip, and three numbered red ones are three bees.
In the first test, the movement of the heroes looks like this.
After selecting the starting vertices. The first move after the bees move. The first move after the Nastya's move. The first bee caught Nastya. In the second test, the movement of the heroes looks like this.
After selecting the starting vertices. The first move after the bees move. The first move after the Nastya's move. The second move after the bees move. The first bee caught Nastya.
In the first test, the movement of the heroes looks like this.
After selecting the starting vertices. The first move after the bees move. The first move after the Nastya's move. The first bee caught Nastya. In the second test, the movement of the heroes looks like this.
After selecting the starting vertices. The first move after the bees move. The first move after the Nastya's move. The second move after the bees move. The first bee caught Nastya.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted