uva-10763-交换生
题意:有一个交换生由A->B,想交换得有一个B->A,问,是不是所有人都能交换成.
俩个数字交换偶数次还是自身,开一个数组mark,模拟完所有样例后,看数组是不是还是初始化数组.
#include "pch.h"
#include <string>
#include<iostream>
#include<map>
#include<memory.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<vector> namespace cc
{
using std::cout;
using std::endl;
using std::cin;
using std::map;
using std::vector;
using std::string;
using std::sort;
using std::priority_queue;
using std::greater;
using std::vector;
using std::swap; constexpr int N = 500001;
//constexpr int N = 30; //priority_queue<int,vector<int>, greater<int> >q; int mark[N];
void init()
{
for (int i = 0;i < N;i++)
mark[i] = i;
} void solve()
{
int n, s, e;
while (cin >> n && n)
{
init();
for (int i = 0;i < n;i++)
{
cin >> s >> e;
auto t = mark[e];
mark[e] = mark[s];
mark[s] = t;
}
int ok = 1;
for (int i = 0;i < N;i++)
if (mark[i] != i)
{
ok = 0;
break;
}
if (ok)
cout << "YES" << endl;
else
cout << "NO" << endl;
} } }; int main()
{ #ifndef ONLINE_JUDGE
freopen("d://1.text", "r", stdin);
#endif // !ONLINE_JUDGE
cc::solve(); return 0;
}
uva-10763-交换生的更多相关文章
- UVA 10763 Foreign Exchange 出国交换 pair+map
题意:给出很多对数字,看看每一对(a,b)能不能找到对应的(b,a). 放在贪心这其实有点像检索. 用stl做,map+pair. 记录每一对出现的次数,然后遍历看看对应的那一对出现的次数有没有和自己 ...
- UVA 10763 Foreign Exchange
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Description Your non- ...
- UVa 10763 Foreign Exchange(map)
Your non-profitorganization (iCORE - international Confederationof Revolver Enthusiasts) coordinates ...
- uva 10763 Foreign Exchange(排序比较)
题目连接:10763 Foreign Exchange 题目大意:给出交换学生的原先国家和所去的国家,交换成功的条件是如果A国给B国一个学生,对应的B国也必须给A国一个学生,否则就是交换失败. 解题思 ...
- Foreign Exchange(交换生换位置)
Foreign Exchange Your non-profit organization (iCORE - international Confederation of Revolver Enth ...
- UVa 10763 (STL) Foreign Exchange
看到大神说location的值不会超过1000,所以这就简单很多了,用一个deg数组记录下来每个点的度,出度-1,入读+1这样. 最后判断每个点的度是否为0即可. 至于为什么会这样,据说是套数据套出来 ...
- uva 10763 Foreign Exchange <"map" ,vector>
Foreign Exchange Your non-profit organization (iCORE - international Confederation of Revolver Enthu ...
- Foreign Exchange UVA - 10763
Your non-profit organization (iCORE - international Confederation of Revolver Enthusiasts) coordin ...
- uva:10763 - Foreign Exchange(排序)
题目:10763 - Foreign Exchange 题目大意:给出每一个同学想要的交换坐标 a, b 代表这位同学在位置a希望能和b位置的同学交换.要求每一位同学都能找到和他交换的交换生. 解题思 ...
随机推荐
- OpenWrt挂载移动硬盘实现脱机下载
一.编译选项选好好usb存储驱动,参考http://www.cnblogs.com/smbx-ztbz/p/4418245.html 并且选上kmod-usb-hid,用于usbhub. 二.编译选项 ...
- jQuery位置操作
position();获取当前标签相对于最近一个父标签中有positon:relative属性的位置. height();标签纯高度 innerHeight();标签内边距padding加上纯高度 o ...
- WCF 基础连接已经关闭: 服务器关闭了本应保持活动状态的连接。
详细错误信息: System.ServiceModel.CommunicationException: 接收对 http://localhost:48655/XXXXXX.svc 的 HTTP 响应时 ...
- 优化sql用到的方法
set statistics profile on set statistics io on set statistics time on declare @begin_date datetime d ...
- 开发人员行走Unix的随身四艺
Unix系统永远只会越来越多,开发人员就没必要特意学习它们的安装.配置和管理了,就全部交给集成人员吧. 但开发人员行走于Unix之间,依然有四样东西要熟练. 一.VI 虽然Unix上的 ...
- windows defender和windows firewall
Windows defender: Windows Defender,曾用名Microsoft Anti Spyware,是一个杀毒程序,可以运行在Windows XP和Windows Server ...
- 学习 MySQL中导入 导出CSV
学习 MySQL中导入 导出CSV http://blog.csdn.net/sara_yhl/article/details/6850107 速度是很快的 导出 select * from t ...
- vlan交换机的端口模式有哪几种
一 端口类型1 ,Access用户模式2 ,Trunk链路模式3 ,Hybrid模式(跟Trunk很类似但比trunk高级)二 端口介绍2.1 ,Access类型端口:只允许默认vlan的以太网帧,也 ...
- C++11--20分钟了解C++11 (下)
20分钟了解C++11 9 override关键字 (虚函数使用) * * 避免在派生类中意外地生成新函数 */ // C++ 03 class Dog { virtual void A(int); ...
- 开启和关闭HBase的thrift进程
开启 $HBASE_HOME/bin/hbase-daemon.sh start thrift [hadoop@bigdatamaster hbase]$ jps 3543 ThriftServer ...