#P7763. [COCI 2016/2017 #5] Ronald
[COCI 2016/2017 #5] Ronald
Description
The cities of a country are connected by undirected air routes.
One operation is defined as:
- Choose one city.
- Open routes from this city to all other cities, and at the same time cancel all existing routes of this city.
Determine whether there exists a sequence of operations (with no limit on the number of operations) such that in the end, there is a direct route between every pair of cities.
Input Format
The first line contains an integer , the number of cities.
The second line contains an integer , the number of initial routes.
The next lines each contain two distinct integers, indicating the two cities connected by that route.
Output Format
If there exists a sequence of operations that satisfies the requirement, output DA. Otherwise, output NE.
2
0
DA
3
2
1 2
2 3
NE
4
2
1 3
2 4
DA
Hint
[Sample 1 Explanation]
It is enough to choose city (that is, open the route ).
[Sample 3 Explanation]
The original routes are and .
Choose city for the first time. Then route is cancelled, and new routes are opened.
Choose city for the second time. Then new routes are opened.
[Constraints]
For of the testdata, , .
[Notes]
This problem is translated from COCI 2016-2017 CONTEST #5 T4 Ronald.
The score of this problem follows the original COCI setting, with a full score of .
Translated by ChatGPT 5
京公网安备 11011102002149号