D :: Enter The Dragon
Time Limit: 10 Seconds Memory Limit: 204800 KB
The capital of Ardenia is surrounded by several lakes, and each of them is initially full of water. Currently, heavy rainfalls are expected over the land. Such a rain falls to one of the lakes: if the lake is dry and empty, then it will be filled with water; if the lake is already full, then it will overflow, which will result in a natural disaster. Fortunately, the citizens have a dragon at their disposal (and they will not hesitate to use it). The dragon may drink the whole water from a lake in one sitting. Also, the mages of Ardenia already predicted the weather conditions for the next couple of years. The only question is: from which lake and when should the dragon drink to prevent a catastrophe?
Input
The input contains several test cases. The first line of the input contains a positive integer Z <= 40, denoting the number of test cases. Then Z test cases follow, each conforming to the format described below.
The first line of the input instance contains two space-separated positive integers n <=106 and m <=106 , where n is the number of lakes. (There are at most 10 input instances for which n >= 105 or m >= 105.) The second line contains the weather forecast for the next m days: m space-separated integers t1, t2,..., tm (ti є [0, n]). If ti є [1, n], it means a heavy rainfall over lake ti at day i. If ti = 0, there is no rain at day i, and the dragon has the time to drink the water from one lake of your choice. Note that the dragon does not drink on a rainy day.
Output
For each test case, your program has to write an output conforming to the format described below.
In the first line your program should output word `YES' if it is possible to prevent a catastrophic overflow and `NO' otherwise. In the former case, you should output the second line containing l integers from the range [0, n], where l is the number of zeros in the weather forecast description, i.e., the number of non-rainy days. Each of these integers denotes the number of the lake from which the dragon should drink; zero means the dragon should not drink from any lake (this might be necessary, as even the dragon cannot drink from an empty lake).
Sample Input
4 2 4 0 0 1 1 2 4 0 1 0 2 2 3 0 1 2 2 4 0 0 0 1
Sample Output
NO YES 1 2 NO YES 0 1 0Submit
Source: Central European Regional Contest 2010