#P10553. [ICPC2024 Xi'an I] Guess The Tree
[ICPC2024 Xi'an I] Guess The Tree
题目描述
There is a full binary tree with levels(so it has exactly nodes). Each node has an integer ID from to , and the IDs form an arrangement from to , but you don't know.
You need to find the IDs of the nodes using at most queries.
输入格式
The first line contains one integer , the levels of the full binary tree.
To ask a query, you need to pick two nodes with IDs , and print the line of the following form:
"? u v"
After that, you will receive:
"t"
The lowest common ancestor's ID of and .
You can ask at most queries.
If you have found the structure of the tree, print a line of the following form:
"! ... "
means the i-th node's father's ID. If it has no father, then .
After printing a query or the answer for a test case, do not forget to output the end of line and flush the output. Otherwise, you will get the verdict 'Idleness Limit Exceeded'. To do this, use:
fflush(stdout)
or cout.flush()
in C++;
System.out.flush()
in Java;
stdout.flush()
in Python.
The interactor in this task is not adaptive.
2
3
3
3
? 1 2
? 2 3
? 1 3
! 3 3 -1
提示
In this case, the tree's root is , it's two sons are and .
For any query "? a b",if , the jury will return answer .
So we found the tree's root is .