题目

题目

 


 

分析

没什么好说的,字符串拼接一下再放进map。其实可以直接开俩数组排序后对比一下,但是我还是想熟悉熟悉map用法。

呃400ms,有点慢。

 


 

代码

#include <bits/stdc++.h>
using namespace std;
int read(string a)
{
int ans=0,i=0;
while(i<a.length()){ans=(ans<<3)+(ans<<1)+a[i]-'0';i++;}
return ans;
}
int main()
{
int n;
while(cin>>n && n!=0)
{
map<string,int> ex;
int maxnum=-1,minnum=1<<13;
for(int i=0;i<n;i++)
{
string x,y; int a,b;
cin>>x>>y;
a=read(x);b=read(y);
minnum=min(minnum,a);minnum=min(minnum,b);
maxnum=max(maxnum,a);maxnum=max(maxnum,b);
ex[x+y]++; ex[y+x]--;
}
bool ok=true;
map<string,int>::iterator it;
it=ex.begin();
while(it!=ex.end()){
if(it->second!=0) ok=false;
it++;
}
if(ok) puts("YES");
else puts("NO");
}
return 0;
}

【UVA】10763 Foreign Exchange(map)的更多相关文章

  1. uva:10763 - Foreign Exchange(排序)

    题目:10763 - Foreign Exchange 题目大意:给出每一个同学想要的交换坐标 a, b 代表这位同学在位置a希望能和b位置的同学交换.要求每一位同学都能找到和他交换的交换生. 解题思 ...

  2. 【UVa】Partitioning by Palindromes(dp)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=27&page=sh ...

  3. 【UVa】1600 Patrol Robot(dfs)

    题目 题目     分析 bfs可以搞,但是我还是喜欢dfs,要记忆化不然会T     代码 #include <cstdio> #include <cstring> #inc ...

  4. 【UVA】1596 Bug Hunt(模拟)

    题目 题目     分析 算是个模拟吧     代码 #include <bits/stdc++.h> using namespace std; map<int,int> a[ ...

  5. 【UVa】1374 Power Calculus(IDA*)

    题目 题目     分析 IDA*大法好,抄了lrj代码.     代码 #include <cstdio> #include <cstring> #include <a ...

  6. 【UVa】439 Knight Moves(dfs)

    题目 题目     分析 没有估价函数的IDA......     代码 #include <cstdio> #include <cstring> #include <a ...

  7. 【BZOJ3680】吊打XXX(模拟退火)

    [BZOJ3680]吊打XXX(模拟退火) 题面 BZOJ 题解 模拟退火... 就是模拟退火 然后这题有毒 各种调参数之后终于\(AC\)了.. 这种题就是玄学呀... 温度要调大 最后跑完还要向四 ...

  8. 【BZOJ3671】【NOI2014】随机数据生成器(贪心)

    [BZOJ3671][NOI2014]随机数据生成器(贪心) 题面 BZOJ 题解 前面的模拟 真的就是语文阅读理解题目 理解清楚题目意思 然后就会发现要求的就是一个贪心 从小往大枚举,检查当前数能不 ...

  9. 【BZOJ2037】Sue的小球(动态规划)

    [BZOJ2037]Sue的小球(动态规划) 题面 BZOJ 题解 莫名想到这道题目 很明显是一样的 设\(f[i][j][0/1]\)表示已经接到了\(i-j\)这一段的小球 当前在\(i\)或者在 ...

随机推荐

  1. CDN加速的实现 --- varnish

    一.什么是CDN cdn全称为内容分发网络(Content Delivery Network).基本思想是尽可能避开互联网上有可能影响数据传输速度和稳定性的瓶颈和环节,是内容传输地更快.更稳定.通过在 ...

  2. flowable DmnEngine和DmnEngineConfiguration

    一.DmnEngineConfiguration创建实例 DmnEngineConfiguration 提供了7个公共的静态方法,用于创建自身实例. 其中5个是使用spring的机制加载配置文件. 另 ...

  3. IOS开发 警告 All interface orientations must be supported unless the app requires full screen.

    在IOS开发中遇到警告  All interface orientations must be supported unless the app requires full screen. 只要勾上R ...

  4. 程序设计入门-C语言基础知识-翁恺-第七周:指针与字符串-详细笔记(七)

    目录 第七周:指针与字符串 7.1 指针初步 7.2 字符类型 7.3 字符串 7.3 课后练习 第七周:指针与字符串 7.1 指针初步 sizeof 是一个运算符,给出某个类型或变量在内存中所占据的 ...

  5. enum枚举类型的定义

    enum枚举类型的定义方式与某种用法 #include <iostream> using namespace std; int main() { enum TOT{ zero, one, ...

  6. skywalking探针tomcat8.0.28报错解决

    在部署skywalking agent的时候遇到一个异常 环境如下: tomcat8.0.28 catalina.out 日志报如下错误 30-Apr-2019 10:25:57.664 INFO [ ...

  7. HDU3394Railway Tarjan连通算法

    There are some locations in a park, and some of them are connected by roads. The park manger needs t ...

  8. object references an unsaved transient instance - save the transient instance before flushing: com.jspxcms.core.domain.ScTeam

    object references an unsaved transient instance - save the transient instance before flushing: com.j ...

  9. waitKey()

    waitKey仅对窗口机制起作用,即namedWindow产生的窗口.若在此之前没有产生窗口,则waitKey相当于未执行. 注:namedWindow产生的窗口: namedWindow()+ims ...

  10. 在VS2013创建WebService并在IIS中发布和使用

    创建WebService 第一步:打开VS2013,新建空项目,注意选择.NET Framework的版本.这里我选择的是.NET Framework 4 新建好项目后,在项目中添加一个WebServ ...