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的更多相关文章

  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. codeforces C. Design Tutorial: Make It Nondeterministic

    题意:每一个人 都有frist name 和 last name! 从每一个人的名字中任意选择 first name 或者 last name 作为这个人的编号!通过对编号的排序,得到每一个人 最终顺 ...

  3. 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 ...

  4. cf472D Design Tutorial: Inverse the Problem

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

  5. cf472B Design Tutorial: Learn from Life

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

  6. cf472A Design Tutorial: Learn from Math

    A. Design Tutorial: Learn from Math time limit per test 1 second memory limit per test 256 megabytes ...

  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. Qsys 设计流程---Qsys System Design Tutorial

    Qsys 设计流程 ---Qsys System Design Tutorial 1.Avalon-MM Pipeline Bridge Avalon-MM Pipeline Bridge在slave ...

  9. D. Design Tutorial: Inverse the Problem 解析含快速解法(MST、LCA、思維)

    Codeforce 472D Design Tutorial: Inverse the Problem 解析含快速解法(MST.LCA.思維) 今天我們來看看CF472D 題目連結 題目 給你一個\( ...

随机推荐

  1. javascript 获取下一个节点

    下一个节点: nextElementSibling 上一个节点 previousElementSibling <div> <select onchange="alert(t ...

  2. linux 文本编辑器 vim 基本操作

    三种模式之间转换: 一般模式 可用于光标移动.复制粘贴.查找替换 "vim.txt"表示文件名 8L 表示8行 , 80C 表示80个字符 移动光标常用操作: h .j. k. l ...

  3. ###《Machine Learning in Action》 - KNN

    初学Python:理解机器学习. 算法是需要实现的,纸上得来终觉浅. // @author: gr // @date: 2015-01-16 // @email: forgerui@gmail.com ...

  4. jQuery 源码分析5: jQuery 基本静态方法(一)

    jQuery在初始化过程中会为自己扩展一些基本的静态方法和属性,以下是jQuery 1.11.3版本 239 ~ 564行间所扩展的静态属性和方法   jQuery.extend({ // 为每个jQ ...

  5. UVA - 572 Oil Deposits(dfs)

    题意:求连通块个数. 分析:dfs. #include<cstdio> #include<cstring> #include<cstdlib> #include&l ...

  6. js闭包的使用例子

    网上关于闭包的介绍太多,这就导致了泛滥,对于新手来说,网上好多讲解就说了闭包是啥,还都是用下面这种例子: 我的天啊,我们都看了不知道多少遍了,看完有啥用?在什么场合下用啊? 于是我翻阅各种资料,自己总 ...

  7. 在Mac OS X中使用VIM开发STM32(3)

    本文原创于http://www.cnblogs.com/humaoxiao,非法转载者请自重!       在上一篇文章中,我们安装了ctags插件,ctags能对我们的源代码文件中的元素建立索引表, ...

  8. 《APUE》第四章笔记(2)

    下面介绍对stat结构的各个成员的操作函数. 先贴个stat结构的图: access函数: #include <unistd.h> int access(const char *pathn ...

  9. mysql---整体备份和增量备份

    整体备份: 对整张表或者整个数据库甚至所有数据库进行备份. 增量备份: 对某一范围内的数据进行备份. 1.整体备份: 对表进行备份: 针对存储引擎为myisam的表,可以直接复制frm.myd.myi ...

  10. C# 解析带前缀的Xml节点内容

    一般的xml文件相信大家都会解析了,但是遇到有命名空间的带前缀的xml,对于新手可能会有点问题.我这里在论坛解答的时候就遇到过一题,见怎么获取XML节点里面的内容,在线求教.这里给大家演示一下. 他的 ...