uva 10763 - Foreign Exchange 水

简介:

     要求严格a-b,b-a,所以分别对a,b排个序,然后比较是不是严格相同

/*
author:jxy
lang:C/C++
university:China,Xidian University
**If you need to reprint,please indicate the source**
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define INF 1E9
using namespace std;
struct edge
{
    int u,v;
    friend bool operator ==(edge a,edge b)
    {
        return a.u==b.v&&a.v==b.u;
    }
};
edge e[500005];
int a[500005],b[500005];
bool cmpa(int A,int B)
{
    if(e[A].u==e[B].u)return e[A].v>e[B].v;
    return e[A].u>e[B].u;
}
bool cmpb(int A,int B)
{
    if(e[A].v==e[B].v)return e[A].u>e[B].u;
    return e[A].v>e[B].v;
}
int main()
{
    int n;
    while(~scanf("%d",&n),n)
    {
        int i;
        for(i=0;i<n;i++)
        {
            scanf("%d%d",&e[i].u,&e[i].v);
            a[i]=b[i]=i;
        }
        sort(a,a+n,cmpa);
        sort(b,b+n,cmpb);
        for(i=0;i<n&&e[a[i]]==e[b[i]];i++);
        if(i!=n)puts("NO");
        else puts("YES");

    }
}



目录
相关文章
uva540 team queue
uva540 team queue
38 0
|
安全 Java fastjson
Ichunqiu云境 —— Exchange Writeup
1. OSCP 渗透风格,脱离C2和MSF之类的工具 2. Box 难度不高