codeforces C. Design Tutorial: Make It Nondeterministic
题意:每一个人 都有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的更多相关文章
- cf472C Design Tutorial: Make It Nondeterministic
C. Design Tutorial: Make It Nondeterministic time limit per test 2 seconds memory limit per test 256 ...
- Design Tutorial: Make It Nondeterministic
Codeforces Round #270:C;http://codeforces.com/contest/472 题意:水题 题解:贪心即可. #include<iostream> #i ...
- codeforces D. Design Tutorial: Inverse the Problem
题意:给定一个矩阵,表示每两个节点之间的权值距离,问是否可以对应生成一棵树, 使得这棵树中的任意两点之间的距离和矩阵中的对应两点的距离相等! 思路:我们将给定的矩阵看成是一个图,a 到 b会有多条路径 ...
- codeforces B. Design Tutorial: Learn from Life
题意:有一个电梯,每一个人都想乘电梯到达自己想要到达的楼层!从a层到b层的时间是|a-b|, 乘客上下电梯的时间忽略不计!问最少需要多少的时间.... 这是一道神题啊,自己的思路不知不觉的就按 ...
- 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\ ...
- 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 ...
- 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 ...
- cf472D Design Tutorial: Inverse the Problem
D. Design Tutorial: Inverse the Problem time limit per test 2 seconds memory limit per test 256 mega ...
- cf472B Design Tutorial: Learn from Life
B. Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes ...
随机推荐
- oracle sqlserver mysql数据库分页
1.Mysql的limit用法 在我们使用查询语句的时候,经常要返回前几条或者中间某几行数据,这个时候怎么办呢?不用担心,mysql已经为我们提供了这样一个功能. SELECT * FROM tabl ...
- C#Winform程序如何发布并自动升级(图解)
C#Winform程序如何发布并自动升级(图解) 有不少朋友问到C#Winform程序怎么样配置升级,怎么样打包,怎么样发布的,在这里我解释一下打包和发布 关于打包的大家可以看我的文章C# w ...
- JVM中的垃圾收集算法和Heap分区简记
如何判断垃圾对象? 垃圾收集的第一步就是先需要算法来标记哪些是垃圾,然后再对垃圾进行处理. 引用计数(ReferenceCounting)算法 这种方法比较简单直观,FlashPlayer/Pyt ...
- Find Minimum in Rotated Sorted Array leetcode java
题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 ...
- Spring MVC+Quartz 定时任务持久化
请自行参考: http://sloanseaman.com/wordpress/2011/06/06/spring-and-quartz-and-persistence/ https://object ...
- C++多线程开发之actor model
最近想把写过的一个多线程程序整理一下,这个程序主要特点是有一系列的互相之间有依赖关系的task.于是在网上找相关类库 1,一类是简单的线程池了,这也是原本俺的做法.之前使用的是手工调度,代码实现的很蛋 ...
- Selenium 3 -how to locate the chromedriver and geckodriver place?
Maybe you met these exceptions sometimes: 1. Chrome Driver The path to the driver executable must be ...
- 利用EEPROM实现arduino的断电存储
转载请注明:@小五义http://www.cnblogs.com/xiaowuyiQQ群:64770604 一.EEPROM简介 EEPROM (Electrically Erasable Progr ...
- 对于程序开发者看书(指实在的书而不是PDF)的好处。(个人看法而已)
书是实在的东西.不同PDF.他能带你进入一种学习态度的环境 书上已经所列了知识点.看了.那些知识点就是你的. 第一次看,未必完全理解到里面的东西.说不定过几天,几周,几个月,甚至几年.再看.就有可能看 ...
- ffrpc的php客户端lib
摘要: ffrpc 是c++异步通讯库,使用ffrpc可以非常容易的构建服务器程序.为了使用方便,ffrpc提供了python.php的客户端lib,这样使用php于c++构建的server也是顺手拈 ...