[2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest][Codeforces 883 G]Orientation of Edges
[Educational Codeforces Round 32][Codeforces 888E]Maximum Subsequence

[2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest][Codeforces 883 M]Quadcopter Competition

Zarxdy34 posted @ 2017年10月23日 09:20 in Codeforces with tags 模拟 , 476 阅读

    题意:在平面直角坐标系上,从(x1,y1)出发,平行坐标轴走一条闭合的轮廓包围点(x2,y2)(x2,y2不在轮廓上),求最短路径。

    题解:走矩形即可。注意特判x1=x2或者y1=y2的情况。

 

#include <bits/stdc++.h>
using namespace std;

int xl,xr,yl,yr;

int main()
{
	scanf("%d%d%d%d",&xl,&yl,&xr,&yr);
	if (xl>xr) swap(xl,xr);
	if (yl>yr) swap(yl,yr);
	printf("%d\n",(xr-xl+1)*2+(yr-yl+1)*2+((xl==xr || yl==yr)?2:0));
	return 0;
}

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter