#P3144. [USACO16OPEN] Closing the Farm S
[USACO16OPEN] Closing the Farm S
Description
FJ and his cows are planning to leave town for a long trip, and FJ wants to temporarily shut down his farm to save some money.
The farm has barns connected by bidirectional roads (). To close the entire farm, FJ plans to close one barn at a time. When a barn is closed, all roads incident to that barn are closed and can no longer be used.
FJ is interested in knowing, at each time (here, “time” means the moment just before each barn is closed), whether his farm is “fully connected” — that is, from any open barn, it is possible to reach any other open barn. Note that from some time onward, the entire farm may cease to be fully connected.
Description
Input Format
The first line contains two integers .
The next lines each contain two integers (), describing a road connecting barns and .
The last lines each contain one integer, where the -th line gives the index of the -th barn to be closed.
Output Format
Output lines, each containing YES or NO, indicating whether the farm is fully connected at that time.
Print the initial status on the first line. On line (), print the status after the -th barn has been closed.
4 3
1 2
2 3
3 4
3
4
1
2
YES
NO
YES
YES
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号