CF311A.The Closest Pair

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.

The problem is the follows. Given n points in the plane, find a pair of points between which the distance is minimized. Distance between (_x_1, _y_1) and (_x_2, _y_2) is .

The pseudo code of the unexpected code is as follows:

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 //here INF is a number big enough
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 //notice that "break" is only to be
//out of the loop "for j"
d=min(d,distance(p[i],p[j]))
output d

Here, tot can be regarded as the running time of the code. Due to the fact that a computer can only run a limited number of operations per second, tot should not be more than k in order not to get Time Limit Exceeded.

You are a great hacker. Would you please help Tiny generate a test data and let the code get Time Limit Exceeded?

目前,Tiny 正在学习计算几何。他在尝试解决一个名为“平面内最近点对”的问题时,发现一段时间复杂度错误的代码竟然通过了(Accepted),而非超时(Time Limit Exceeded)。

问题描述如下:给定平面上的 nn 个点,找出其中距离最小的一对点。点 (x1,y1)(x_1, y_1) 与 (x2,y2)(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 // here INF is a number big enough  
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 可视为该代码的实际运行时间(即执行的内层循环体次数)。由于计算机每秒只能执行有限次数的操作,为避免超时(Time Limit Exceeded),tot 的值不应超过 kk。

你是一位出色的黑客。请帮助 Tiny 构造一组测试数据,使得该代码触发超时(Time Limit Exceeded)。

输入格式

A single line which contains two space-separated integers n and k (2 ≤ n ≤ 2000, 1 ≤ k ≤ 109).

一行,包含两个以空格分隔的整数 nn 和 kk(2 ≤ n ≤ 20002 \leq n \leq 2000,1 ≤ k ≤ 1091 \leq k \leq 10^9)。

输出格式

If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers x__i, y__i (|x__i|, |y__i| ≤ 109) representing the coordinates of the i-th point.

The conditions below must be held:

  • All the points must be distinct.
  • |x__i|, |y__i| ≤ 109.
  • After running the given code, the value of tot should be larger than k.

如果不存在使给定代码超时(TLE)的数据,则输出 "no solution"(不带引号);否则输出 n 行,其中第 i 行包含两个整数 x__i, y__i(满足 | x__i |, | y__i | ≤ 10⁹),表示第 i 个点的坐标。

需满足以下条件:

  • 所有点必须互不相同。
  • | x__i |, | y__i | ≤ 10⁹。
  • 运行给定代码后,变量 tot 的值应大于 k。

输入输出样例

  • 输入#1

    4 3

    输出#1

    0 0
    0 1
    1 0
    1 1
  • 输入#2

    2 100

    输出#2

    no solution

输入解题思路,AI测评打分。不知道怎么写?

首页