NOI Contest Archive

Archive / 2023 / Final Round — Day 1

Visit Sri Lanka

Medium · National Olympiad in Informatics Sri Lanka 2023 - Day 1

The Tourist Board of Sri Lanka wants to contribute more to the economy by increasing revenue from tourism. With that intention, they decided to develop facilities in cities in a subset of all the cities. The proposal with the list of cities needs to be approved by Mr X the president of Sri Lanka. He approves a proposal that looks cost-effective according to his criteria. A proposal is cost-effective only if all the proposed cities are located on a single path from Colombo or at least there is an immediate neighbouring city which is on that path.

The bidirectional road network of Sri Lanka connects each city such that there is only one unique shortest path between every pair of cities(Cities and roads form a tree). A path is a sequence of roads which joins a sequence of cities without any repeating cities.

There is n number of cities and n-1 roads that connects cities. There is only one road between each pair of neibouring cities and there are no roads from a city to itself. The tourist board has m proposal with different subsets of cities. The director of the tourist board wants your assistance to decide which proposals are approvable and which are not.

Input Format

Cities are named from 1 to n. Colombo is named as 1.

Output Format

Output m lines. The output of ith line should be ‘Approved’ if the proposal meets the president’s criteria. Otherwise output ‘Declined’.

Constraints

1 \(\leq\) n \(\leq\) 105 1 \(\leq\) m \(\leq\) 105

Sum of Ci \(\leq\) 3*105 (0 \(\leq\) i \(\leq\) m-1)

Limits

Sample Input 0

8 2
1 2
1 3
2 5
3 4
3 6
4 8
4 7
3 3 6 8
2 5 7

Sample Output 0

Approved
Declined