您的位置:首页 > 其它

Codeforces Round #261 (Div. 2) A. Pashmak and Garden【水】

2014-08-17 19:19 501 查看
A. Pashmak and Garden

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

Pashmak has fallen in love with an attractive girl called Parmida since one year ago...

Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the garden looks like a square with sides parallel to the coordinate axes. He also remembers that there is
exactly one tree on each vertex of the square. Now, Pashmak knows the position of only two of the trees. Help him to find the position of two remaining ones.

Input

The first line contains four space-separated x1, y1, x2, y2 ( - 100 ≤ x1, y1, x2, y2 ≤ 100) integers,
where x1 and y1 are
coordinates of the first tree and x2 and y2 are
coordinates of the second tree. It's guaranteed that the given points are distinct.

Output

If there is no solution to the problem, print -1. Otherwise print four space-separated integers x3, y3, x4, y4 that
correspond to the coordinates of the two other trees. If there are several solutions you can output any of them.

Note that x3, y3, x4, y4 must
be in the range ( - 1000 ≤ x3, y3, x4, y4 ≤ 1000).

Sample test(s)

input
0 0 0 1


output
1 0 1 1


input
0 0 1 1


output
0 1 1 0


input
0 0 1 2


output
-1


题意:已知正方形两角,求另外两角。

本以为斜放的时候不好办,结果题目认定斜放输出-1,看0 0 1 2就行

所以就是水题了,对三种位置关系判断就行

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define NMAX 500001
#define FOR(i,n) for(int i=0;i<n;i++)

struct node
{
int x,y;
}a[6];
int main()
{
int n,tx,ty;
//freopen("A.txt","r",stdin);
scanf("%d%d%d%d",&a[0].x,&a[0].y,&a[1].x,&a[1].y);
{
int dy = abs(a[1].y - a[0].y);
int dx = abs(a[1].x - a[0].x);
if(dx == 0)    //y equals
{
a[2].x = a[0].x + dy,a[2].y = a[0].y;
a[3].x = a[1].x + dy,a[3].y = a[1].y;
printf("%d %d %d %d\n",a[2].x,a[2].y,a[3].x,a[3].y);
}
else if(dy == 0)
{
a[2].x = a[0].x ,a[2].y = a[0].y + dx;
a[3].x = a[1].x ,a[3].y = a[1].y + dx;
printf("%d %d %d %d\n",a[2].x,a[2].y,a[3].x,a[3].y);
}
else if(dx == dy)
{
a[2].x = a[0].x,a[2].y = a[1].y;
a[3].x = a[1].x,a[3].y = a[0].y;
printf("%d %d %d %d\n",a[2].x,a[2].y,a[3].x,a[3].y);
}
else
printf("-1\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐