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 題目連結 題目 給你一個\( ...
随机推荐
- LintCode 55 比较字符串
比较两个字符串A和B,确定A中是否包含B中所有的字符.字符串A和B中的字符都是 大写字母 注意事项 在 A 中出现的 B 字符串里的字符不需要连续或者有序. 样例 给出 A = "ABC ...
- [原创]HTML标签总结!! 第一次画 尚需要改进 多关照
HTML 页面标签总结 拿xMind写了一下午总结的 只能传图片了 CSS明天整理 后天看看能不能传上来 //======================================= ...
- Java简单算法--求100以内素数
package cn.magicdu.algorithm; /** * 打印素数 * * @author xiaoduc * */ public class Prim { public static ...
- 恢复被误操作删除的数据 fn_dblog
-- Script Name: Recover_Deleted_Data_Proc -- Script Type : Recovery Procedure -- Develop By: Muhamm ...
- 学习笔记1_Day09_Servlet
生命周期方法: l void init(ServletConfig):出生之后(1次): l void service(ServletRequest request, ServletRespons ...
- lua package path 设置方法
lua package path 设置方法: 添加环境变量LUA_PATH="/add_path/?.lua;;" 1.add_path为新添加的目录: 2.一定要添加双引号: 3 ...
- 12天学好C语言——记录我的C语言学习之路(Day 10)
12天学好C语言--记录我的C语言学习之路 Day 10: 接着昨天的指针部分学习,有这么一个题目: //还是四个学生,四门成绩,只要有学生一门功课没及格就输出这个学生的所有成绩 /*//progra ...
- 使用FOR循环语句在屏幕上输出一个由星号组成的直角三角形
题目要求: 请用C++的信息输出方式,使用循环语句在屏幕上输出一个由星号组成的直角三角形,形状如下: * ** *** **** ***** 要求: 完全使用C++的信息输出方式,即cout以及流插入 ...
- Unity中使物体自动寻路的方法
在做一个FPS游戏时,需要敌方自动找到玩家方位并向玩家移动,在查找资料(并走了不少坑)后,我试了三个方法,经测试,这三个方法都能实现自动寻路功能. 方法一:使用Mathf.Lerp()方法 代码很简单 ...
- 创建线程的两种方式比较Thread VS Runnable
1.首先来说说创建线程的两种方式 一种方式是继承Thread类,并重写run()方法 public class MyThread extends Thread{ @Override public vo ...