#P6499. [COCI 2016/2017 #2] Burza
[COCI 2016/2017 #2] Burza
Description
Daniel and Stjepan are playing a game on a tree with nodes, where the nodes are numbered . At the start of the game, there is a coin on node .
The rules are as follows:
- Daniel chooses a node and marks it.
- Stjepan marks the node where the coin is currently located.
- Stjepan moves the coin to a node that is unmarked and adjacent to the current node.
Repeat the above steps. When Stjepan cannot move the coin, the game ends.
Daniel wants to know whether there exists a fixed strategy such that, no matter how Stjepan plays, the game can be ended within rounds. That is, the number of times Stjepan can move the coin is less than .
Input Format
The first line contains two integers .
The next lines each contain two integers , indicating that there is an edge between nodes numbered and .
Output Format
If there exists a strategy that satisfies the condition, output one line DA.
Otherwise, output one line NE.
6 2
1 2
2 3
3 4
1 5
5 6
DA
3 1
1 2
1 3
NE
8 2
1 2
2 3
2 4
5 6
6 8
1 5
7 1
DA
Hint
Sample Explanation
Sample 2 Explanation
- If Daniel marks node , Stjepan can move the coin to node or node .
- If Daniel marks node , Stjepan can move the coin to node .
- If Daniel marks node , Stjepan can move the coin to node .
In all cases, the game cannot be ended within round.
So, there is no strategy that satisfies the condition.
Sample 3 Explanation
- In the first round, Daniel marks node .
- In the second round, Daniel marks node .
No matter how Stjepan plays, he cannot move the coin for the second time.
So, there exists a strategy that satisfies the condition.
Constraints
For of the testdata, , .
Notes
This problem is translated from COCI2016-2017 CONTEST #2 T6 Burza.
Translated by ChatGPT 5
京公网安备 11011102002149号