#abc209d. D - Collision
D - Collision
Score : points
问题描述
王国高桥由 个城镇和 条道路组成,这些城镇依次编号为 至 。第 条道路()连接城镇 和城镇 ,因此通过使用某些道路可以从任意一个城镇到达任意一个城镇。所有道路的长度均相同。
你将收到 个查询。在第 个查询中 ,给出整数 和 ,解决以下问题:
- 高桥现在位于城镇 ,而青木现在位于城镇 。他们将同时离开各自的城镇,并以相同速度开始旅行,高桥朝着城镇 行进,青木朝着城镇 行进。判断他们将在某个城镇相遇还是在半路上相遇。在此假设两者都沿最短路径行进,并且穿越城镇所需的时间可以忽略不计。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
The Kingdom of Takahashi is made up of towns and roads, where the towns are numbered through . The -th road connects Town and Town , so that you can get from every town to every town by using some roads. All the roads have the same length.
You will be given queries. In the -th query , given integers and , solve the following problem:
- Takahashi is now at Town and Aoki is now at Town . They will leave the towns simultaneously and start traveling at the same speed, Takahashi heading to Town and Aoki heading to Town . Determine whether they will meet at a town or halfway along a road. Here, assume that both of them travel along the shortest paths, and the time it takes to pass towns is negligible.
Constraints
- All values in input are integers.
- It is possible to get from every town to every town by using some roads.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain Town
if Takahashi and Aoki will meet at a town in the -th query, and Road
if they meet halfway along a road in that query.
Sample Input 1
4 1
1 2
2 3
2 4
1 2
Sample Output 1
Road
In the first and only query, Takahashi and Aoki simultaneously leave Town and Town , respectively, and they will meet halfway along the -st road, so we should print Road
.
Sample Input 2
5 2
1 2
2 3
3 4
4 5
1 3
1 5
Sample Output 2
Town
Town
In the first query, Takahashi and Aoki simultaneously leave Town and Town , respectively, and they will meet at Town , so we should print Town
.
In the first query, Takahashi and Aoki simultaneously leave Town and Town , respectively, and they will meet at Town , so we should print Town
.
Sample Input 3
9 9
2 3
5 6
4 8
8 9
4 5
3 4
1 9
3 7
7 9
2 5
2 6
4 6
2 4
5 8
7 8
3 6
5 6
Sample Output 3
Town
Road
Town
Town
Town
Town
Road
Road
Road
update @ 2024/3/10 09:22:59