A15908 | Fading into Fog
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
This is an interactive problem.
There are $n$ distinct hidden points with real coordinates on a two-dimensional Euclidean plane. In one query, you can ask some line $ax + by + c = 0$ and get the projections of all $n$ points to this line in some order. The given projections are not exact, please read the interaction section for more clarity.
Using the minimum number of queries, guess all $n$ points and output them in some order. Here minimality means the minimum number of queries required to solve any possible test case with $n$ points.
The hidden points are fixed in advance and do not change throughout the interaction. In other words, the interactor is not adaptive.
A projection of point $A$ to line $ax + by + c = 0$ is the point on the line closest to $A$ .
There are $n$ distinct hidden points with real coordinates on a two-dimensional Euclidean plane. In one query, you can ask some line $ax + by + c = 0$ and get the projections of all $n$ points to this line in some order. The given projections are not exact, please read the interaction section for more clarity.
Using the minimum number of queries, guess all $n$ points and output them in some order. Here minimality means the minimum number of queries required to solve any possible test case with $n$ points.
The hidden points are fixed in advance and do not change throughout the interaction. In other words, the interactor is not adaptive.
A projection of point $A$ to line $ax + by + c = 0$ is the point on the line closest to $A$ .
输入格式
The first line contains a single integer $t$ ( $1 \leq t \leq 50$ ) — the number of test cases.
The description of the test cases follows.
The first line of each test case contains a single integer $n$ ( $2 \leq n \leq 25$ ) — the number of hidden points.
For each test case, it is guaranteed that for any pair of hidden points, their $x$ coordinates differ by at least $1$ . Analogously, $y$ coordinates of any pair also differ by at least $1$ .
Coordinates $x$ and $y$ of all hidden points do not exceed $100$ by absolute value.
The description of the test cases follows.
The first line of each test case contains a single integer $n$ ( $2 \leq n \leq 25$ ) — the number of hidden points.
For each test case, it is guaranteed that for any pair of hidden points, their $x$ coordinates differ by at least $1$ . Analogously, $y$ coordinates of any pair also differ by at least $1$ .
Coordinates $x$ and $y$ of all hidden points do not exceed $100$ by absolute value.
输出格式
To query a line $ax + by + c = 0$ you should print "? a b c" where all a, b and c are real numbers up to $100$ by absolute value. For less precision issues numbers $a$ and $b$ must satisfy the condition $|a| + |b| \geq 0.1$ , where $|a|$ is the absolute value of $a$ .
As an answer to the query you will get $n$ points in the form "x\_1 y\_1 ... x\_n y\_n", where points $(x_i, y_i)$ are projections to the line $ax + by + c = 0$ . It is guaranteed that each printed point is no more than $10^{-4}$ away from the real projection point. Every coordinate is printed with at most 9 decimal places.
See the interaction example for more clarity.
If you ask too many queries, you will get Wrong answer.
To output an answer you should print "! x\_1 y\_1 ... x\_n y\_n", where $(x_i, y_i)$ are coordinates of the hidden points. You could output the hidden points in any order. The answer would be considered correct if each of the printed points is no more than $10^{-3}$ away from the corresponding hidden point. Printing the answer doesn't count as a query.
After printing a query or the answer, do not forget to output 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
Hacks
To make a hack, use the following test format.
In the first line output a single integer $t$ ( $1 \leq t \leq 50$ ) — the number of test cases.
The description of the test cases follows.
In the first line of each test case output a single integer $n$ ( $2 \leq n \leq 25$ ). In the next $n$ lines output two rational numbers each. The numbers in line $i$ should correspond to $x_i$ and $y_i$ respectively. Printed points must comply with all constraints from the input section.
As an answer to the query you will get $n$ points in the form "x\_1 y\_1 ... x\_n y\_n", where points $(x_i, y_i)$ are projections to the line $ax + by + c = 0$ . It is guaranteed that each printed point is no more than $10^{-4}$ away from the real projection point. Every coordinate is printed with at most 9 decimal places.
See the interaction example for more clarity.
If you ask too many queries, you will get Wrong answer.
To output an answer you should print "! x\_1 y\_1 ... x\_n y\_n", where $(x_i, y_i)$ are coordinates of the hidden points. You could output the hidden points in any order. The answer would be considered correct if each of the printed points is no more than $10^{-3}$ away from the corresponding hidden point. Printing the answer doesn't count as a query.
After printing a query or the answer, do not forget to output 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
Hacks
To make a hack, use the following test format.
In the first line output a single integer $t$ ( $1 \leq t \leq 50$ ) — the number of test cases.
The description of the test cases follows.
In the first line of each test case output a single integer $n$ ( $2 \leq n \leq 25$ ). In the next $n$ lines output two rational numbers each. The numbers in line $i$ should correspond to $x_i$ and $y_i$ respectively. Printed points must comply with all constraints from the input section.
输入输出样例
输入 #1
1 2 1 1 2.5 1 1.500000001 1.500000000 2 2
输出 #1
? 0 1 -1 ? 0.2 -0.2 0 ! 1 3 2.5 0.500000001
In the sample the hidden points are $(1, 3)$ and $(2.5, 0.5)$
A picture, which describes the first query:

A picture, which describes the second query:

A picture, which describes the first query:

A picture, which describes the second query:

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted