Codeforces Beta Round #14 (Div. 2) C. Four Segments 水题

C. Four Segments

题目连接:

http://codeforces.com/contest/14/problem/C

Description

Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him.

Input

The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points.

Output

Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO».

Sample Input

1 1 6 1
1 0 6 0
6 0 6 1
1 1 1 0

Sample Output

YES

Hint

题意

给你四条边,问你这四条边能不能恰好组成一个不退化的矩形。

题解:

两条线段横着,两条线段竖着,每个端点都被两条直线覆盖就行。

代码

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

int f,x1,x2,y1,y2,x,y;
map<pair<int,int>,int>H;
int main()
{
    for(int i=0;i<4;i++)
    {
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        x+=(y1==y2)&&(x1!=x2);
        y+=(x1==x2)&&(y1!=y2);
        H[make_pair(x1,y1)]++;
        H[make_pair(x2,y2)]++;
    }
    f=(x==2)&&(y==2);
    map<pair<int,int>,int>::iterator it;
    for(it=H.begin();it!=H.end();it++)
        if(it->second!=2)
            f=0;
    if(f)printf("YES\n");
    else printf("NO\n");
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值