Codeforces Round #261 (Div. 2) A

Description

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, y( - 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 integersx3, 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).

Examples
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
解法:额,自己想怎么构造就怎么构造
复制代码
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int x1,y1,x2,y2;
 6     cin>>x1>>y1>>x2>>y2;
 7     if(x1!=x2&&y1!=y2)
 8     {
 9         if(abs(x1-x2)!=abs(y1-y2))
10         {
11             cout<<"-1";
12         }
13         else
14         {
15             cout<<x1<<" "<<y2<<" "<<x2<<" "<<y1<<endl;
16         }
17     }
18     else
19     {
20         if(x1==x2)
21         {
22             cout<<x1+abs(y1-y2)<<" "<<y1<<" "<<x2+abs(y1-y2)<<" "<<y2<<endl;
23         }
24         else
25         {
26             cout<<x1<<" "<<y1+abs(x1-x2)<<" "<<x2<<" "<<y2+abs(x1-x2)<<endl;
27         }
28     }
29     return 0;
30 }
复制代码

 

posted @   樱花落舞  阅读(248)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示