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. js回调函数callback()

    <a id="btnSave" href="javascript:void(0)" class="easyui-linkbutton" ...

  2. 搭建scala开发环境

    下载scala 2.11.5 安装eclipse LUNA版本 安装scala IDE插件:http://download.scala-ide.org/sdk/lithium/e44/scala211 ...

  3. .net 邮件批量发送功能源码

    #define debug   using System; using System.Text; using System.Linq; using System.IO; using System.Ne ...

  4. linux启动报错:kernel panic - not attempted to kill init

    系统类型:CentOS 6.4(x64) 启动提示:Kernel panic - not syncing: Attempted to kill init 解决办法: 系统启动的时候,按下‘e’键进入g ...

  5. 11_Servlet基础知识

    [概念] Servlet通常被称为服务端小程序,是运行在服务端的程序,用于处理及相应客户端的请求. Servlet是用java语言开发网页动态资源的技术. [特点] 1.Servlet是个特殊的Jav ...

  6. C++ 泛型编程/模板 泛函编程/Lambda/λ演算

    1.泛型编程(C++模板) 其中,Ada, Delpha, Java, C#, Swift 称之为 泛型/generics; ML, Scala和 Haskell 称之为 参数多态/parametri ...

  7. ifstream:incomplete type is not allowed

    IntelliSense: incomplete type is not allowed ifstream inputFile; Need to add this: #include <fstr ...

  8. POJ 1080 Human Gene Functions -- 动态规划(最长公共子序列)

    题目地址:http://poj.org/problem?id=1080 Description It is well known that a human gene can be considered ...

  9. 九度OJ 1528 最长回文子串 -- Manacher算法

    题目地址:http://ac.jobdu.com/problem.php?pid=1528 题目描述: 回文串就是一个正读和反读都一样的字符串,比如"level"或者"n ...

  10. 第30条:用enum代替int常量

    在java1.5之前,表示枚举类型的常用模式是声明一组具名的int常量,每个类型成员一个常量: public static final int APPLE_FUJI = 0; public stati ...