题解 | Magic Line-2019牛客暑期多校训练营第三场H题

本文提供了2019年牛客暑期多校训练营第三场H题——Magic Line的详细解题思路和示例解析,包括输入输出描述。作者分享了题解和解决方案,并鼓励读者访问牛客竞赛区获取更多题目讨论和详细信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss
题目描述:
在这里插入图片描述
输入描述:
在这里插入图片描述
输出描述:
在这里插入图片描述
示例1:
在这里插入图片描述
题解:
在这里插入图片描述
代码:

#include<bits/stdc++.h>
#define N 100005
using namespace std;
const int oo=(1e9)-(1e6);
struct Point{
	int x,y;
	int operator < (const Point &b)const{
		return x<b.x||x==b.x&&y<b.y;
	}
	long long operator * (const Point &b)const{
		return 1ll*x*b.y-1ll*y*b.x;
	}
	Point operator - (const Point &b)const{
		return (Point){x-b.x,y-b.y};
	}
	int operator == (const Point &b)const{
		return x==b.x&&y==b.y;
	}
}a[N];
int main(){
	//freopen("C.in","r",stdin);
	//freopen("C.out","w",stdout);
	int T=1e9;
	scanf("%d",&T);
	while (T--){
		int n;scanf("%d",&n);
		for (int i=1;i<=n;i++)
			scanf("%d%d",&a[i].x,&a[i].y);
		/*int n;
		while (true){
			n=rand()%4+1;
			for (int i=1;i<=n;i++) a[i].x=rand()%11-5,a[i].y=rand()%11-5;
			int line=0;
			for (int i=1;i<=n;i++)
				for (int j=i+1;j<=n;j++){
					line|=a[i]==a[j];
					for (int k=j+1;k<=n;k++)
						if ((a[k]-a[i])*(a[j]-a[i])==0) line=1;
				}
			if (!line) break;
		}*/
		//printf("%d\n",n);
		sort(a+1,a+n+1);
		printf("%d %d %d %d\n", a[n/2].x-1,a[n/2].y+oo+1,a[n/2].x+1,a[n/2].y-oo);
	}
}

更多问题,更详细题解可关注牛客竞赛区,一个刷题、比赛、分享的社区。
传送门:https://ac.nowcoder.com/acm/contest/discuss

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值