Design Tutorial: Make It Nondeterministic
Codeforces Round #270:C;http://codeforces.com/contest/472
题意:水题
题解:贪心即可。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=1e5+;
int n;
char str1[N][];
char str2[N][];
int a[N];
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%s %s",str1[i],str2[i]);
}
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
int temp=;
bool flag=false;
if(strcmp(str1[a[]],str2[a[]])<){
temp=;
}
else
temp=;
//printf("%d\n",temp);
for(int i=;i<=n;i++){
// printf("%d %d\n",a[i-1],temp);
if(strcmp(str1[a[i]],str2[a[i]])<){
if(temp==){
if(strcmp(str1[a[i]],str1[a[i-]])>){
temp=;
continue;
}
if(strcmp(str2[a[i]],str1[a[i-]])<){
flag=true;
break;
} }
else{
if(strcmp(str1[a[i]],str2[a[i-]])>){
temp=;
continue;
}
if(strcmp(str2[a[i]],str2[a[i-]])<){
flag=true;
break;
} }
temp=; }
else{ if(temp==){
if(strcmp(str2[a[i]],str1[a[i-]])>){
temp=;
continue;
}
if(strcmp(str1[a[i]],str1[a[i-]])<){
flag=true;
break;
} }
else{
if(strcmp(str2[a[i]],str2[a[i-]])>){
temp=;
continue;
}
if(strcmp(str1[a[i]],str2[a[i-]])<){
flag=true;
break;
} }
temp=; }
}
if(flag)puts("NO");
else
puts("YES"); }
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 ... 
- codeforces C. Design Tutorial: Make It Nondeterministic
		题意:每一个人 都有frist name 和 last name! 从每一个人的名字中任意选择 first name 或者 last name 作为这个人的编号!通过对编号的排序,得到每一个人 最终顺 ... 
- 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 ... 
- 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 ... 
- cf472A Design Tutorial: Learn from Math
		A. Design Tutorial: Learn from Math time limit per test 1 second memory limit per test 256 megabytes ... 
- 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 ... 
- Qsys 设计流程---Qsys System Design Tutorial
		Qsys 设计流程 ---Qsys System Design Tutorial 1.Avalon-MM Pipeline Bridge Avalon-MM Pipeline Bridge在slave ... 
- D. Design Tutorial: Inverse the Problem 解析含快速解法(MST、LCA、思維)
		Codeforce 472D Design Tutorial: Inverse the Problem 解析含快速解法(MST.LCA.思維) 今天我們來看看CF472D 題目連結 題目 給你一個\( ... 
随机推荐
- 用于主题检测的临时日志(fe4edac1-b4f4-4673-ae87-110cbb7dbb5a - 3bfe001a-32de-4114-a6b4-4005b770f6d7)
			这是一个未删除的临时日志.请手动删除它.(25ea5485-9168-424b-a30c-09cc1371e2d9 - 3bfe001a-32de-4114-a6b4-4005b770f6d7) 
- cookie管理中的一些细节,转的
			1.domain表示的是cookie所在的域,默认为请求的地址,如网址为www.jb51.net/test/test.aspx,那么domain默认为www.jb51.net.而跨域访问,如域A为t1 ... 
- java学习笔记3
			今天在练习java中的javabean的使用中发现.usebean的 <jsp:setProperty property="id" name="user" ... 
- C#5.0之后推荐使用TPL(Task Parallel Libray 任务并行库) 和PLINQ(Parallel LINQ, 并行Linq). 其次是TAP(Task-based Asynchronous Pattern, 基于任务的异步模式)
			学习书籍: <C#本质论> 1--C#5.0之后推荐使用TPL(Task Parallel Libray 任务并行库) 和PLINQ(Parallel LINQ, 并行Linq). 其次是 ... 
- 九度OJ 1505 两个链表的第一个公共结点 【数据结构】
			题目地址:http://ac.jobdu.com/problem.php?pid=1505 题目描述: 输入两个链表,找出它们的第一个公共结点. 输入: 输入可能包含多个测试样例. 对于每个测试案例, ... 
- grant授权“失败”的原因
			在创建用户的时候我们通常采用grant命令完成,并同时赋予相应的权限,例如我们创建一个名为test的用户,g并赋予其对数据库foo下所有表格select,delete,drop,create权限: g ... 
- DataList和Repeater
			DataList和Repeater是两个十分有用的控件,在新闻列表和图片展示的地方经常用到.在这里简单的把他们介绍一下. 1.DataList: 前端页面: <asp:DataList ID=& ... 
- 使用XmlPullParser对xml进行读取
			XML文件是一种标记性语言;在开发中经常在接口交互时被用作报文传输或者把自定义的类序列化为XML的形式存储到数据库.正因为XML文件这么常用,使用JAVA对XML文件进行读写操作是每一个开发人员必须掌 ... 
- hdu 5056 Boring count
			贪心算法.需要计算分别以每个字母结尾的且每个字母出现的次数不超过k的字符串,我们设定一个初始位置s,然后用游标i从头到尾遍历字符串,使用map记录期间各个字母出现的次数,如果以s开头i结尾的字符串满足 ... 
- js实现克隆一个对象
			var app={}; app.cloneobj= function(obj){ var o; if(typeof obj == "object"){ if(obj===null) ... 
