C. The Closest Pair

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/312/problem/C

Description

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(x1, y1) and (x2, y2) 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?

Input

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

Output

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 xi, yi (|xi|, |yi| ≤ 109) representing the coordinates of the i-th point.

The conditions below must be held:

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

Sample Input

4 3

Sample Output

0 0
0 1
1 0
1 1

HINT

题意

给你一个程序,要求让你出一组数据,使得这组数据会让程序的tot超过k

题解:

很显然我们可以发现,他只是比较了x之间的距离,那么我们可以构造出所有点的x都相同,y都不相同的数据就好了

这样任意两个点的距离一定是大于任意两个点的x坐标之差的

代码:

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std; int main()
{
long long n,k;
cin>>n>>k;
if(k>=((n*(n-1LL))/2LL))
return puts("no solution");
for(int i=;i<n;i++)
printf("1 %d\n",i);
}

Codeforces Round #185 (Div. 2) C. The Closest Pair 构造的更多相关文章

  1. Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)

    题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数 ...

  2. Codeforces Round #185 (Div. 1 + Div. 2)

    A. Whose sentence is it? 模拟. B. Archer \[pro=\frac{a}{b}+(1-\frac{a}{b})(1-\frac{c}{d})\frac{a}{b}+( ...

  3. 【Codeforces Round #185 (Div. 2) C】The Closest Pair

    [链接] 链接 [题意] 让你构造n个点,去hack一种求最近点对的算法. [题解] 让x相同. 那么那个剪枝就不会起作用了. [错的次数] 在这里输入错的次数 [反思] 在这里输入反思 [代码] # ...

  4. Codeforces Round #185 (Div. 2) B. Archer 水题

    B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...

  5. Codeforces Round #185 (Div. 2) A. Whose sentence is it? 水题

    A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  6. 【Codeforces Round #185 (Div. 2) D】Cats Transport

    [链接] 链接 [题意] 有n座山,m只猫. 每只猫都在其中的一些山上玩. 第i只猫在h[i]山上玩,且会在t[i]时刻出现在山脚下(然后就一直在那里等) 然后有p个人. 它们听从你的安排. 在某个时 ...

  7. 【Codeforces Round #185 (Div. 2) B】Archer

    [链接] 链接 [题意] 在这里输入题意 [题解] 概率水题. 枚举它是第几轮成功的. 直到满足精度就好 [错的次数] 1 [反思] long double最让人安心. [代码] #include & ...

  8. 【Codeforces Round #185 (Div. 2) A】 Whose sentence is it?

    [链接] 链接 [题意] 告诉你每句话; 然后每句话是谁说的和开头与结尾的一段字符串有关. [题解] 一个一个判断就好; 注意大小<5的情况 [错的次数] 在这里输入错的次数 [反思] 在这里输 ...

  9. Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题

    C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...

随机推荐

  1. C 的 coroutine 库 via 云风的 BLOG

    今天实现了一个 C 用的 coroutine 库. 我相信这个东西已经被无数 C 程序员实现过了, 但是通过 google 找了许多, 或是接口不让我满意, 或是过于重量. 在 Windows 下, ...

  2. WAPI

    中国制定的WLAN安全标准WAPI 针对WLAN安全问题,中国制定了自己的WLAN安全标准:WAPI. 与其他无线局域网安全机制(如802.11i)相比,WAPI主要的差别体现在以下几个方面: • 双 ...

  3. 反转链表 --剑指offer

    题目:定义一个函数,输入一个链表的头结点,反转该链表并输出反正后链表的头结点. #include<stdio.h> #include<malloc.h> typedef str ...

  4. Linux 系统编程

    简介和主要概念 Linux 系统编程最突出的特点是要求系统程序员对它们工作的的系统的硬件和操作系统有深入和全面的了解,当然它们还有库和系统调用上的区别. 系统编程分为:驱动编程.用户空间编程和网络编程 ...

  5. UINavigationController 操作记录

    //设置字体大小 颜色 { UIColor *color = [UIColor brownColor]; UIFont * font = [UIFont systemFontOfSize:20]; N ...

  6. IOS 屏幕截图 UIScrollview

    //截图UIView:截全图 -(UIImage*)captureView:(UIView *)theView{ CGRect rect = theView.frame; if ([theView i ...

  7. Linux基本命令(3)文件备份和压缩命令

    文件备份和压缩命令 在Linux中,常用的文件压缩工具有gzip.bzip2.zip.bzip2是最理想的压缩工具,它提供了最大限度的压缩.zip兼容性好,Windows也支持. 命令 功能 bzip ...

  8. Centos yum源更新为阿里云

    阿里云镜像网址 http://mirrors.aliyun.com/   更新步骤 1.备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d ...

  9. trate

    from sklearn.feature_extraction.text import CountVectorizer from sklearn.feature_extraction.text imp ...

  10. mac搭建PHP开发环境

    在Mac系统上搭建Php服务器环境: LAMP: Linux Apache MySQL PHP MAMP: MACOS APACHE(自带) MYSQL(需自己安装) PHP(自带) 一.APACHE ...