A group of $$$n$$$ friends went to Troodos mountains for hiking. Each friend has a phone, and the $$$i$$$-th phone initially has a charge of $$$a_i$$$ units. All phones are of the same model, and the maximum battery capacity for each phone is $$$M$$$ units.
They also have a single power bank with a total charge capacity of exactly $$$n \cdot M$$$ units, which is sufficient to fully charge all $$$n$$$ phones to their maximum.
However, the power bank can only be connected to one phone at a time. It can be reconnected to different phones as needed.
Friends are a bit tired, so they can't switch the power bank from one phone to another too often. The maximum number of switches is some given integer $$$S$$$.
For risk management, friends also came up with a rule that at any point in time during the charging process, the difference in charge between any two phones should not exceed $$$D$$$ units.
Your task is to find the minimum possible value of $$$D$$$ such that it is possible to fully charge all phones while satisfying both rules. Note that the answer may be non-integer and also in some cases such $$$D$$$ doesn't exist. See output section for more details.
If it is not possible to meet the above conditions for any value of $$$D$$$, output $$$-1$$$, otherwise output one real number $$$D$$$. Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{|a-b|}{\max(1, |b|)} \le 10^{-6}$$$
This task contains six subtasks. To get the points for the subtask, your solution should pass all the tests in the corresponding subtask.
| Subtask | Constraints | Points |
| $$$1$$$ | $$$a_i = 0$$$ | $$$10$$$ |
| $$$2$$$ | $$$S \leq 10^6$$$ | $$$25$$$ |
| $$$3$$$ | $$$n \leq 2$$$ | $$$9$$$ |
| $$$4$$$ | $$$n \leq 3$$$ | $$$12$$$ |
| $$$5$$$ | $$$n \geq 10$$$, $$$S = 10^9$$$, $$$M = 10^{18}$$$, $$$a_i$$$ are randomly generated | $$$8$$$ |
| $$$6$$$ | no additional constraints | $$$36$$$ |
2 7 20 0
3.5
4 10 17 8 9 10
-1
3 5 51 2 3
2
In the first example, we should charge the first phone to $$$3.5$$$ units, then fully charge the second phone, then fully charge the first phone.
This is an interactive problem.
During the excavation at the ruins of the ancient city-kingdom of Salamis archaeologist found a hidden royal tomb, buried at an unknown depth of $$$n$$$ meters below the surface. Your task is to find the number $$$n$$$ by making experiments with your digging bot.
In each experiment, you give the bot a set of integer numbers $$$a_1, a_2, ..., a_k$$$, and ask it to dig from the surface (depth 0) to depth $$$n$$$, using only steps of length $$$a_i$$$. That means, if the bot's current depth is $$$x$$$, it can move to depths $$$x + a_1$$$, $$$x + a_2$$$, ..., or $$$x + a_k$$$. When the bot reaches the depth $$$n$$$, it tells you the number of steps it made. The bot is very intelligent and always makes the minimal possible number of steps to reach the depth $$$n$$$.
For example, let the hidden number be $$$n = 23$$$. If you give the bot a set $$$a = [1, 3, 8]$$$, it can reach depth $$$n$$$ in 5 steps (for example $$$0 \rightarrow 3 \rightarrow 4 \rightarrow 7 \rightarrow 15 \rightarrow 23$$$), and if you give the bot a set $$$a = [9, 5]$$$, it can reach depth $$$n$$$ in 3 steps ($$$0 \rightarrow 9 \rightarrow 18 \rightarrow 23$$$).
Your task is to guess the number $$$n$$$ after making several experiments with the following constraints:
Your solution will be tested on 100 tests. If your solution fails to guess the number $$$n$$$, or exceeds the given limits in at least one test, it will get 0 points.
If your solution successfully guesses the number $$$n$$$, and does not exceed the limits in all tests, the score will be calculated based on the total number of steps the bot made in all experiments.
Let $$$s_i$$$ be the total number of steps the bot made in all experiments in test $$$i$$$, and let $$$S$$$ be maximum of $$$s_i$$$ for all 100 tests. Then your score will be calculated based on the following table:
| $$$S$$$ | Score |
| $$$\le 100$$$ | 100 |
| $$$101-150$$$ | 95 |
| $$$151-200$$$ | 90 |
| $$$201-250$$$ | 80 |
| $$$251-300$$$ | 70 |
| $$$301-500$$$ | 60 |
| $$$501-1000$$$ | 50 |
| $$$1001-5000$$$ | 20 |
| $$$5001-20000$$$ | 10 |
| $$$20001-30000$$$ | 5 |
| $$$\ge 30001$$$ | 0 |
To make an experiment, your program should print one line of the form: "? k $$$a_1$$$ $$$a_2$$$ $$$...$$$ $$$a_k$$$", where $$$k$$$ ($$$1\le k\le 250$$$) is the size of the set and $$$a_i$$$ $$$(1 \le a_i \le 30000)$$$ are the elements of the set. After that, your program should read a single integer $$$m$$$, the minimum number of steps the bot needed to do to reach the depth $$$n$$$.
When your program is ready to guess the number $$$n$$$, it should output the following line: "! $$$n$$$". After that, your program should exit.
After printing each query do not forget to output the end of line and flush the output.
If, at any interaction step, you read $$$-1$$$ instead of valid data, your solution must exit immediately. This means that your solution will receive Wrong answer because of an invalid query or any other mistake. Failing to exit can result in an arbitrary verdict because your solution will continue to read from a closed stream.
To flush, use:
5 3
? 3 1 3 8 ? 2 9 5 ! 23
Andreas has a tree with $$$n$$$ nodes (undirected connected graph without cycles).
Andreas and Eleni will play the following game:
$$${\dagger}$$$ The distance between two nodes of a tree is the length (in edges) of the shortest path between these nodes.
If there are no other nodes that can be chosen the game ends and the player who makes the last move wins.
Who will win the game if both players play optimally?
You already know that Andreas really wants to win so you need to find the answer for every starting node.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 3 \cdot 10^{5}$$$) — the number of nodes and the number $$$k$$$.
The $$$i^{th}$$$ of the following $$$n−1$$$ lines in the test case contains two positive integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i,v_i \le n$$$), meaning that there exists an edge between them in the graph.
It is guaranteed that the given edges form a tree.
For each test case, print $$$n$$$ integer — the $$$i^{th}$$$ integer should be $$$1$$$ if the first player wins with starting node $$$i$$$ otherwise it should be $$$0$$$.
| Subtask | Constraints | Points | |
| $$$\sum {n}$$$ | Additional | ||
| $$$1$$$ | $$$\sum {n} \le 3 \cdot 10^{5}$$$ | Every node $$$j$$$ ($$$j \neq 1$$$) has a direct edge to $$$1$$$ (the tree is a star) | $$$3$$$ |
| $$$2$$$ | $$$\sum {n} \le 3 \cdot 10^{5}$$$ | There is an edge from every $$$i$$$ to $$$i+1$$$ ($$$1 \le i \le n-1$$$) (the tree is a line) | $$$5$$$ |
| $$$3$$$ | $$$\sum {n} \le 10^{3}$$$ | $$$k = n$$$ | $$$7$$$ |
| $$$4$$$ | $$$\sum {n} \le 3 \cdot 10^{5}$$$ | $$$k = n$$$ | $$$8$$$ |
| $$$5$$$ | $$$\sum {n} \le 50$$$ | — | $$$12$$$ |
| $$$6$$$ | $$$\sum {n} \le 3 \cdot 10^{5}$$$ | $$$k = 1$$$ | $$$10$$$ |
| $$$7$$$ | $$$\sum {n} \le 700$$$ | — | $$$15$$$ |
| $$$8$$$ | $$$\sum {n} \le 5000$$$ | — | $$$17$$$ |
| $$$9$$$ | $$$\sum {n} \le 3 \cdot 10^{5}$$$ | — | $$$23$$$ |
32 11 26 21 21 33 44 54 64 31 22 33 4
0 00 1 1 0 1 10 0 0 0
In the first test case, no matter how they will play all of the nodes will be selected so the second player always wins.
Below you can see a way that the second player will win in the second test case if the starting node was $$$1$$$.
![]() | ![]() | ![]() | ![]() |
Blue nodes are those that were selected by the first player, and red nodes are those that were selected by the second player.