【牛客网多校】19-7-25-H题 Magic Line

匿名 (未验证) 提交于 2019-12-02 23:52:01

链接:https://ac.nowcoder.com/acm/contest/883/H
来源:牛客网

  • 题目描述

There are always some problems that seem simple but is difficult to solve. ZYB got

Help him draw this magic line.

输入描述:

 

输出描述:

 
示例1

输入

1 4 0 1 -1 0 1 0 0 -1

输出

-1 999000000 1 -999000001
 
 1 #include<bits/stdc++.h>  2 using namespace std;  3 typedef long long ll;  4 struct p  5 {  6     ll x,y;  7 }ps[1002];  8 bool cmpx(struct p a,struct p b)  9 { 10     return a.x<b.x; 11 } 12 bool cmpy(struct p a,struct p b) 13 { 14     if(a.y!=b.y) return a.y<b.y; 15     else return a.x>b.x; 16 } 17 int main() 18 { 19     ll t,n; 20     scanf("%lld",&t); 21     while(t--){ 22         ll x1,y1,x2,y2; 23         scanf("%lld",&n); 24         for (ll i=0;i<n;i++){ 25             scanf("%lld %lld",&ps[i].x,&ps[i].y); 26         } 27         sort(ps,ps+n,cmpy); 28         x1=(ps[n/2-1].x); 29         y1=ps[n/2-1].y; 30         x2=(ps[n/2].x); 31         y2=ps[n/2].y; 32         x1-=999000000; 33         x2+=999000000; 34         if (y1==y2) { 35             y1-=1; 36             y2+=1; 37         } 38         printf("%lld %lld %lld %lld\n",x1,y1,x2,y2); 39     } 40     return 0; 41 }
 

 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!