题意:
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
给出n和k,构造n个不同的点,使得这段代码的时间复杂度(tot)大于k. n<=2000,k<=1e9,
构造的点范围为[-1e9,1e9].
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
给出n和k,构造n个不同的点,使得这段代码的时间复杂度(tot)大于k. n<=2000,k<=1e9,
构造的点范围为[-1e9,1e9].
构造:让n个点的横坐标距第一相等,则任意两个横坐标之差为0 都不可能大于最短距离 跑满(n-1)*(n-1+1)/2次
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,mod=1e9+7;
int n,k;
int main()
{
cin>>n>>k;
int num=n*(n-1)/2;
if(k>=num)
{
puts("no solution");
return 0;
}
for(int i=1;i<=n;i++)
printf("%d %d\n",0,i);
return 0;
}