题意:每一个人 都有frist name 和 last name! 从每一个人的名字中任意选择
first name 或者 last name 作为这个人的编号!通过对编号的排序,得到每一个人
最终顺序!比较中的序列能否得到给定输出的序列一致!

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<map>
#include<algorithm>
#define N 100005
using namespace std; int p[N];
string name[*N];
map<string, int>mp;//将每一个人名字映射到是第几个人 int main(){
int n;
int cnt=;
cin>>n;
for(int i=; i<=n; ++i){
cin>>name[cnt++]>>name[cnt++];
mp.insert(make_pair(name[cnt-], i));
mp.insert(make_pair(name[cnt-], i));
}
for(int i=; i<=n; ++i)//每个人的排序之后的序列
cin>>p[i];
sort(name, name+cnt);//排序
int k = ;
for(int i=; i<cnt; ++i)//贪心
if(mp[name[i]] == p[k]){
++k;
if( k > n) break;
}
if(k>n) cout<<"YES";
else cout<<"NO";
cout<<endl;
return ;
}

codeforces C. Design Tutorial: Make It Nondeterministic的更多相关文章

  1. cf472C Design Tutorial: Make It Nondeterministic

    C. Design Tutorial: Make It Nondeterministic time limit per test 2 seconds memory limit per test 256 ...

  2. Design Tutorial: Make It Nondeterministic

    Codeforces Round #270:C;http://codeforces.com/contest/472 题意:水题 题解:贪心即可. #include<iostream> #i ...

  3. codeforces D. Design Tutorial: Inverse the Problem

    题意:给定一个矩阵,表示每两个节点之间的权值距离,问是否可以对应生成一棵树, 使得这棵树中的任意两点之间的距离和矩阵中的对应两点的距离相等! 思路:我们将给定的矩阵看成是一个图,a 到 b会有多条路径 ...

  4. codeforces B. Design Tutorial: Learn from Life

    题意:有一个电梯,每一个人都想乘电梯到达自己想要到达的楼层!从a层到b层的时间是|a-b|, 乘客上下电梯的时间忽略不计!问最少需要多少的时间....     这是一道神题啊,自己的思路不知不觉的就按 ...

  5. Codeforces.472F.Design Tutorial: Change the Goal(构造 线性基 高斯消元)

    题目链接 \(Description\) 给定两个长为\(n\)的数组\(x_i,y_i\).每次你可以选定\(i,j\),令\(x_i=x_i\ \mathbb{xor}\ x_j\)(\(i,j\ ...

  6. Codeforces #270 D. Design Tutorial: Inverse the Problem

    http://codeforces.com/contest/472/problem/D D. Design Tutorial: Inverse the Problem time limit per t ...

  7. Codeforces Round #270--B. Design Tutorial: Learn from Life

    Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes in ...

  8. cf472D Design Tutorial: Inverse the Problem

    D. Design Tutorial: Inverse the Problem time limit per test 2 seconds memory limit per test 256 mega ...

  9. cf472B Design Tutorial: Learn from Life

    B. Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes ...

随机推荐

  1. Extjs4中RadioGroup的赋值与取值

    1.定义rg var rg = new Ext.form.RadioGroup({ fieldLabel : "test", items : [{ boxLabel : '每天', ...

  2. android: 使用 IntentService

    9.5.2 使用 IntentService 话说回来,在本章一开始的时候我们就已经知道,服务中的代码都是默认运行在主线程 当中的,如果直接在服务里去处理一些耗时的逻辑,就很容易出现 ANR(Appl ...

  3. 分享45个设计师应该见到的新鲜的Web移动设备用户界面PSD套件

    对于一个网页设计师来说做一个好的PSD模板是非常有挑战性的一项任务,虽然PSD的模板简化了设计任务,但找出高质量的PSD文件,可以自由使用,是一 项艰巨的任务.你必须通过许多网页去找出一个极少数的PS ...

  4. 禁用iOS的UIView长按默认操作

    * {    -webkit-touch-callout: none;    -webkit-user-select: none;    -webkit-tap-highlight-color: rg ...

  5. LeetCode:Roman to Integer,Integer to Roman

    首先简单介绍一下罗马数字,一下摘自维基百科 罗马数字共有7个,即I(1).V(5).X(10).L(50).C(100).D(500)和M(1000).按照下述的规则可以表示任意正整数.需要注意的是罗 ...

  6. MinStack

    Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. pu ...

  7. Grunt 新手指南

    导言 作为一个正在准备从java 后端转大前端,一直都有想着,在js 的世界里面有没有类似于maven或者gradle 的东西..然后,就找到了grunt 这玩意 Grunt是用来干什么的 诸如ant ...

  8. WPF 触发器

    属性触发器:数据触发器:事件触发器

  9. svg―Raphael.js Library(一)

    Raphael是一个用于在网页中绘制矢量图形的Javascript库,它使用SVG W3C推荐标准和VML作为创建图形的基础,可以通过JavaScript操作DOM来轻松创建出各种复杂的柱状图.饼图. ...

  10. java知识大全积累篇

    原文出自:http://www.importnew.com/14429.html 构建 这里搜集了用来构建应用程序的工具. Apache Maven:Maven使用声明进行构建并进行依赖管理,偏向于使 ...