H. Mysterious Photos(相似三角形)

H. Mysterious Photos

time limit per test

2.0 s

memory limit per test

256 MB

input

standard input

output

standard output

Everyone probably heard the rumours about the constellation of Bermuda Triangle: any person who looks to this constellation of three stars is said to disappear completely. Though, it's not clear who then spreads these rumours.

Recently two photos have been sent to the editorial office of the newspaper you work on. Each photo depicts three glowing points on the dark background. The note applied to the photos indicates that they are the photos of the constellation of the Bermuda Triangle.

Of course, the editors cannot check if it's true without the risk of the stuff. But at least it is possible to make sure that each photo depicts the same triple of stars. Remember that photos could be taken with the different zoom and rotation. They could also be taken with the help of a mirror in order to decrease the risk of triggering the curse.

As a regular programmer of the newspaper you have the task to determine if these photos can depict the same triple of stars.

Input

The input consists of 6 lines. Each of the first three lines contains two integers separated by space — the coordinates of stars on the first photo. Each of the next three lines also contains two integers — the coordinates of stars on the second photo. All coordinates are between - 104 and 104, inclusively. Stars on each photo don't coincide and don't lie on the same line.

Output

Output «YES» if the photos can depict the same triple of stars and «NO» otherwise.

Examples

input

Copy

0 0
0 2
1 0
0 0
0 4
2 0

output

Copy

YES

input

Copy

0 0
0 2
1 0
0 0
0 4
3 0

output

Copy

NO

input

Copy

5 5
7 6
6 3
1 0
0 1
1 1

output

Copy

YES

题目连接:http://codeforces.com/gym/100187/problem/H

#include <cstdio>
#include <algorithm>
using namespace std;
struct Node
{
	long long x;
	long long y;
};
int main()
{
	Node a[3],b[3];
	long long  len1[3],len2[3];
	int i;
	for(i=0;i<3;i++)
    scanf("%lld%lld",&a[i].x,&a[i].y);
	for(i=0;i<3;i++)
    scanf("%lld%lld",&b[i].x,&b[i].y);
	for(i=0;i<3;i++)
	{
		long long tx=a[i].x-a[(i+1)%3].x;
		long long ty=a[i].y-a[(i+1)%3].y;
		len1[i]=tx*tx+ty*ty;
		tx=b[i].x-b[(i+1)%3].x;
		ty=b[i].y-b[(i+1)%3].y;
		len2[i]=tx*tx+ty*ty;
	}
	sort(len1,len1+3);
	sort(len2,len2+3);
	double temp=1.0*len1[0]/len2[0];
	for(i=1;i<3;i++)
	{
		if(1.0*len1[i]/len2[i]!=temp)
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/xigongdali/article/details/81589982