苍天有泪 发表于 2015-11-24 14:13:01

uva 10763 Foreign Exchange我认为我这种做法最符合题意!

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
//freopen(&quot;out.txt&quot;,&quot;w&quot;,stdout);
//freopen(&quot;in.txt&quot;,&quot;r&quot;,stdin);
//ios::sync_with_stdio(false);
struct node{
int x,y;
bool operator < (const node& a)const {
if(x == a.x )
return y < a.y;
else
return x < a.x;
}
};
node a;
node b;

int main()
{
int n;
while(scanf(&quot;%d&quot;,&n),n)
{
for(int i = 0;i < n;i++)
{
scanf(&quot;%d%d&quot;,&a.x,&a.y);
b.x = a.y;
b.y = a.x;
}
sort(a,a+n);
sort(b,b+n);
int flag = 1;
for(int i = 0;i < n;i++)
{
if(memcmp(&a,&b,sizeof(node)) != 0)
{
flag = 0;
}
}
if(flag)
printf(&quot;YES\n&quot;);
else
printf(&quot;NO\n&quot;);
}
return 0;
}</pre><pre code_snippet_id=&quot;640726&quot; snippet_file_name=&quot;blog_20150410_3_4436580&quot; name=&quot;code&quot; class=&quot;cpp&quot;>我认为这种方法才是最符合题意的,虽然这里面数据很差,但是这种做法才是比较正确的!
页: [1]
查看完整版本: uva 10763 Foreign Exchange我认为我这种做法最符合题意!