#P6976. [NEERC2015] Distance on Triangulation
[NEERC2015] Distance on Triangulation
题目描述
You have a convex polygon. The vertices of the polygon are successively numbered from to . You also have a triangulation of this polygon, given as a list of diagonals.
You are also given queries. Each query consists of two vertex indices. For each query, find the shortest distance between these two vertices, provided that you can move by the sides and by the given diagonals of the polygon, and the distance is measured as the total number of sides and diagonals you have traversed.
输入格式
The first line of the input file contains an integer -- the number of vertices of the polygon .
Each of the following lines contains two integers -- the ends of the i-th diagonal
The next line contains an integer -- the number of queries .
Each of the following lines contains two integers -- the vertices in the i-th query .
It is guaranteed that no diagonal coincides with a side of the polygon, and that no two diagonals coincide or intersect.
输出格式
For each query output a line containing the shortest distance.
题目大意
给定一个正 边形及其三角剖分, 共 条边 ( 条多边形的边和 条对角线), 每条边的长度为 。
共 次询问, 每次询问给定两个点, 求它们的最短距离。
Translated by Eason_AC
2020.11.19
6
1 5
2 4
5 2
5
1 3
2 5
3 4
6 3
6 6
2
1
1
3
0
提示
Time limit: 2 s, Memory limit: 256 MB.