#P1854D. Michael and Hotel
Michael and Hotel
No submission language available for this problem.
Description
Michael and Brian are stuck in a hotel with rooms, numbered from to , and need to find each other. But this hotel's doors are all locked and the only way of getting around is by using the teleporters in each room. Room has a teleporter that will take you to room (it might be that ). But they don't know the values of .
Instead, they can call up the front desk to ask queries. In one query, they give a room , a positive integer , and a set of rooms . The hotel concierge answers whether a person starting in room , and using the teleporters times, ends up in a room in .
Brian is in room . Michael wants to know the set of rooms so that if he starts in one of those rooms they can use the teleporters to meet up. He can ask at most queries.
The values are fixed before the start of the interaction and do not depend on your queries. In other words, the interactor is not adaptive.
The input contains a single integer ().
Interaction
To ask a query, print a line in the format "? u k |S| S_1 S_2 ... S_|S|" with , all the distinct, and .
As a response to the query you will get "1" if the answer is yes, and "0" if the answer is no.
To output an answer, you should print "! |A| A_1 A_2 ... A_|A|" with all distinct. Printing the answer doesn't count as a query.
See the interaction example for more clarity.
If you ask too many queries or you ask a malformed query, you will get Wrong answer.
After printing a query do not forget to output the end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- see the documentation for other languages.
Hack format
For the hacks use the following format.
The first line should contain — the number of rooms.
The second line should contains integers — the teleporter in room leads to room .
Input
The input contains a single integer ().
Note
In the sample test, there are rooms and the (hidden) array describing the behavior of the teleporters is .
- The first query asks whether starting from room number , and using the teleporters times, one ends up in one of the two rooms . This action results in ending up in the room , so the answer is .
- The second query asks whether starting from room number , and using the teleporters times, one ends up in one of the two rooms . This action results in ending up in the room , so the answer is .