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 題目連結 題目 給你一個\( ...
随机推荐
- SpriteFrameCache 精灵帧缓存
//获取精灵帧缓存的单例对象 auto spriteFrameCache = SpriteFrameCache::getInstance(); //从plist文件添加多个精灵帧 spriteFra ...
- mysql 5.5 win7安装最后一步总是停止响应
今天刚开始安装了64位版本的mysql5.5 ,安装很顺利,后来发现库不兼容的问题,于是卸载,安装mysql-5.5.27-win32的32位版本,奇怪了,怎么安装,怎么卸载都不行,就是到最 后一步停 ...
- 无责任比较thrift vs protocol buffers
http://blog.csdn.net/socoolfj/article/details/3855007 最新版本的Hadoop代码中已经默认了Protocol buffer作为RPC的默认实现,原 ...
- 以 280W 数据为依据。对比SQL2008 表分区前和分区后的 T_SQL 效率
一: 数据库的优化一直项目后期的重中之重,特别是当单表数据庞大到1000W时候.各种SQL语句执行效率都会慢很多.SQL 效率 与索引,行数据,列数据,以及Where 刷选字段类型 (效率 整数型大于 ...
- HTTP 错误 500.21 - Internal Server Error的解决方案
开始菜单>所有程序>附件>命令提示符(以管理员的身份运行) 然后运行下面的命令注册: 32位机器: C:\Windows\Microsoft.NET\Framework\v4.0.3 ...
- ACM——快速排序法
快速排序 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:653 测试通过:297 描述 给定输入排序元素数目 ...
- linux中的常用命令
cat tail -f 日 志 文 件 说 明 /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一 /var/log/secure 与安全相关 ...
- __nonnull 和 __nullable (Swift 和 Objective-C混编)
苹果在 Xcode 6.3 以后,为了解决 Swift 与 OC 混编时的问题,引入了一个 Objective-C 的新特性:nullability annotations. 这一新特性的核心是两个新 ...
- oc 一些通用函数
1 i= 0,1,2... unichar c = [self characterAtIndex:i]; //取出i这个位置对应的字符 2 拼凑字符串 [NSString stringWithForm ...
- Java实战之03Spring-02Spring的核心之IoC
二.Spring的核心之IoC(Inversion of Control 控制反转) 1.IoC是什么? 回顾:连接池原理中的使用. 注意:我们在连接池原理中是使用构造函数注入的,当然还可以通过提供s ...