#include <bits/stdc++.h>
using namespace std;
struct node
{
long long x,y,index;
}arr[10010];
bool cmp(node n1,node n2)
{
if(n1.x!=n2.x)
return n1.x<n2.x;
return n1.y<n2.y;
}
vector<int> vec;
int main()
{
long long n,i,dx,dy;
while(cin>>n)
{
for(i=0;i<n;i++)
{
scanf("%lld%lld",&arr[i].x,&arr[i].y);
arr[i].index=i+1;
}
sort(arr,arr+n,cmp);
dx=1;
dy=-(1<<30);
vec.clear();
for(i=0;i<n-1;i++)
{
if((arr[i+1].y-arr[i].y)*dx>dy*(arr[i+1].x-arr[i].x))
{
vec.clear();
dy=arr[i+1].y-arr[i].y;
dx=arr[i+1].x-arr[i].x;
}
if((arr[i+1].y-arr[i].y)*dx==dy*(arr[i+1].x-arr[i].x))
{
vec.push_back(i);
dy=arr[i+1].y-arr[i].y;
dx=arr[i+1].x-arr[i].x;
}
}
for(i=0;i<vec.size();i++)
{
printf("%lld %lld\n",arr[vec[i]].index,arr[vec[i]+1].index);
}
}
}
51nod 1100 斜率最大
最新推荐文章于 2022-02-26 16:52:46 发布