CF311A The Closest Pair
题目描述
Tiny 目前正在学习计算几何。在尝试解决题目“平面最近点对”时,他发现有一份时间复杂度不正确的代码却被判定为通过,而没有超时。
题目如下。给定平面上的 $ n $ 个点,找到一对点使得它们之间的距离最小。$(x_1, y_1)$ 和 $(x_2, y_2)$ 之间的距离为 。
这段意外通过的代码的伪代码如下:
```
input n
for i from 1 to n
input the i-th point's coordinates into p[i]
sort array p[] by increasing of x coordinate first and increasing of y coordinate second
d=INF //这里的 INF 足够大
tot=0
for i from 1 to n
for j from (i+1) to n
++tot
if (p[j].x-p[i].x>=d) then break //注意“break”只会跳出“for j”循环
d=min(d,distance(p[i],p[j]))
output d
```
这里,$ tot $ 可以看作代码的运行次数。由于计算机每秒只能运行有限次操作,$ tot $ 不应超过 $ k $,否则会超时。
你是一个出色的黑客。你能帮 Tiny 生成一组让这份代码超时的数据吗?
输入格式
一行包含两个用空格分隔的整数 $ n $ 和 $ k $($2 \leq n \leq 2000$,$1 \leq k \leq 10^9$)。
输出格式
如果不存在能够让代码超时的数据,请输出“no solution”。否则输出 $ n $ 行,第 $ i $ 行包含两个整数 $ x_i,y_i $($|x_i|,|y_i| \leq 10^9$),表示第 $ i $ 个点的坐标。
必须满足以下条件:
- 所有点的坐标都不相同;
- $|x_i|,|y_i| \leq 10^9$;
- 执行上述代码后,$tot$ 的值应严格大于 $k$。
说明/提示
由 ChatGPT 5 翻译