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
output
input
output
input
output
题意:已知正方形两角,求另外两角。
本以为斜放的时候不好办,结果题目认定斜放输出-1,看0 0 1 2就行
所以就是水题了,对三种位置关系判断就行
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; }
相关文章推荐
- Codeforces Round #261 (Div. 2) C. Pashmak and Buses
- Codeforces Round #261 (Div. 2)459D. Pashmak and Parmida's problem(求逆序数对)
- Codeforces Round #261 (Div. 2) D. Pashmak and Parmida's problem
- Codeforces Round #261 (Div. 2)B. Pashmak and Flowers(容易)
- Codeforces Round #261 (Div. 2)——Pashmak and Buses
- Codeforces Round #299 (Div. 1)C. Tavas and Pashmaks
- Codeforces Round 261 Div.2 D Pashmak and Parmida&#39;s problem --树状数组
- Codeforces Round 261 Div.2 E Pashmak and Graph --DAG上的DP
- Codeforces Round #299 (Div. 1)C. Tavas and Pashmaks (凸壳)
- Codeforces Round 261 Div.2 E Pashmak and Graph --DAG上的DP
- Codeforces Round #378 (Div. 2)A. Grasshopper And the String
- Codeforces Round #416 (Div. 2) C - Vladik and Memorable Trip
- Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] C. Weakness and Poorness 三分 dp
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) E. The Holmes Children
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 枚举+二分
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle(分形)
- 【Codeforces Round 354 (Div 2)D】【迷宫搜索BFS】Theseus and labyrinth 门门互达 可做旋转操作 最少步数起点到终点
- Codeforces Round #341 (Div. 2) E. Wet Shark and Blocks(矩阵优化DP)
- 【Codeforces Round 370 (Div 2) E】【线段树 等比数列 区间合并】Memory and Casinos 赌场区间[l,r] l进r先出的概率
- Codeforces Round #293 (Div. 2) C. Anya and Smartphone 数学题