PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000043. Kiểm tra tập đỉnh trắc địa (The Geodetic Set Problem)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Kiểm tra tập đỉnh trắc địa (The Geodetic Set Problem)
The Geodetic Set Problem
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A set is geodetic in an unweighted connected undirected graph when every vertex lies on some shortest path between two vertices of . Answer subset queries.
Input
Integer , followed by adjacency-list lines for vertices through (possibly empty), then and lines each listing a nonempty vertex subset.
Output
Print yes for every geodetic query set and no otherwise.
Subtasks
- Subtask 1 (40 points): ; , ; connected simple undirected graph; each subset is nonempty and contains no repeated vertex.
- Subtask 2 (60 points): , ; connected simple undirected graph; each subset is nonempty and contains no repeated vertex.
Examples
Input
5
2 3
1 3 4
1 2 5
2 5
3 4
3
1 2 5
2 4
3 4 5
Output
yes
no
no
Explanation
The set {1,2,5} covers all vertices through shortest paths between selected endpoints; the other two proposed sets leave at least one vertex uncovered.