[codeforces 1271C] Shawarma Tent 模拟(曼哈顿距离)

[codeforces 1271C]   Shawarma Tent   模拟(曼哈顿距离)

总目录详见https://blog.csdn.net/mrcrack/article/details/103564004

在线测评地址http://codeforces.com/contest/1271/problem/C

ProblemLangVerdictTimeMemory
C - Shawarma Tent GNU C++11Accepted78 ms0 KB

下面代码对应的

Examples

Input

4 3 2
1 3
4 2
5 1
4 1

Output

3
4 2

Input

3 100 100
0 0
0 0
100 200

Output

2
100 0

Input

7 10 12
5 6
20 23
15 4
16 5
4 54
12 1
4 15

Output

4
10 6
    #include <stdio.h>
    #define INF 1000000100
    int n,sx,sy,x,y;
    int up=0,down=0,left=0,right=0;
    int xright=INF,xleft=-1,yup=INF,ydown=-1;
    int sumx,xpos,sumy,ypos;
    int min(int a,int b){
    	return a<b?a:b;
    }
    int max(int a,int b){
    	return a>b?a:b;
    }
    int main(){
    	int i;
    	scanf("%d%d%d",&n,&sx,&sy);
    	for(i=1;i<=n;i++){
    		scanf("%d%d",&x,&y);
    		
    		if(x>sx)right++,xright=min(xright,x);
    		else if(x<sx)left++,xleft=max(xleft,x);
    		
    		if(y>sy)up++,yup=min(yup,y);
    		else if(y<sy)down++,ydown=max(ydown,y);
    	}
    	
    	if(right>left)sumx=right,xpos=xright;
    	else sumx=left,xpos=xleft;
     
    	if(up>down)sumy=up,ypos=yup;
    	else sumy=down,ypos=ydown;
    	
    	if(sumx>sumy)printf("%d\n%d %d\n",sumx,xpos,sy);
    	else printf("%d\n%d %d\n",sumy,sx,ypos);
    	
    	return 0;
    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值