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");

    }
}
时间: 2024-08-17 00:07:40

uva 10763 - Foreign Exchange 水的相关文章

UVa 10763 Foreign Exchange

10763 - Foreign Exchange Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1704 Your non-profit organization (iCORE - internationalConfederation of Revolve

UVa 10763:Foreign Exchange

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1704 原题: Your non-profit organization (iCORE - international Confederation of Revolver Enthusiasts) coordinates a very succes

利用正则表达式将html网页数据变成Web Service

web|数据|网页|正则 这次的题目很简单,中国银行有一个查当天汇率的网页(http://www.bank-of-china.com/info/qpindex.shtml),不过是传统的Html格式,而其又没有提供Xml格式或者WebService查询.现在如果希望其他的信息系统能够随时读取其中的数据,那么方便的莫过于中行提供一个WebService接口供大家调用,这也是典型的安全的WebService应用.可惜中行没有做,那么我们能不能自己来做呢?当然可以,只要用程序分析其html网页,那么就

如何使用 Cdosys.dll 库使用ASP发送邮件带附件

 <%@ Language=VBScript CODEPAGE=65001%> <% Response.Buffer=True %> <% 'Collaboration Data Objects, version 1.2.1(CDO) 'http://www.microsoft.com/downloads/details.aspx?FamilyId=2714320D-C997-4DE1-986F-24F081725D36&displaylang=en '-------

外商投资中国房产仍有难度

尽管中国政府在去年7月份宣布了相关措施,旨在为过热的房地产市场降温,但外国投资者仍在继续涌入这个市场. 来自国家统计局(National Bureau of Statistics)的数据显示,包括香港和澳门在内,中国2006年的房地产投资总额约为180亿美元.内地房地产市场的外资接近82.5亿美元,较2005年增长51.9%.另外,国家发展和改革委员会(NDRC)的数据显示,今年第一季度,投向房地产市场的外资达17亿美元,较去年同期增长154.4%. 值得注意的是,房地产行业外商投资的变化,一方

算法题之UVA 763

Fibinary Numbers The standard interpretation of the binary number 1010 is 8 + 2 = 10. An alternate way to view the sequence ``1010'' is to use Fibonacci numbers as bases instead of powers of two. For this problem, the terms of the Fibonacci sequence

UVA 10405 Longest Common Subsequence:简单DP

省赛还有不到50天了,自己DP这块实在是弱,准备就拿着些天狂刷DP了. http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1346 大意: 求两个字符串的最长公共子序列. 思路:水题,不过需要注意的就是字符串里可能会出现空格,需要用gets,真是坑. 更多精彩内容:http://www.bianceng.cnhttp://www.biancen

UVa 10400

链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1341 类型:回溯 原题: A game show in Britain has a segment where it gives its contestants a sequence of positive numbers and a target

UVa 784:Maze Exploration 搜索专题

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=105&page=show_problem&problem=725 题目类型: 搜索 样例输入: 2 XXXXXXXXX X X X X * X X X X XXXXXXXXX X X X X X X XXXXX _____ XXXXX X X X * X X X XXXXX _____ 样例输出: XXXX