【思维】Kenken Race
题目描述
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
4≤N≤200000
S is a string of length N consisting of . and #.
1≤A,B,C,D≤N
Square A, B, C and D do not contain a rock.
A, B, C and D are all different.
A<B
A<C
B<D
输入
N A B C D
S
输出
样例输入
7 1 3 6 7
.#..#..
样例输出
Yes
提示
The objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)
A#B.#..
A#.B#..
.#AB#..
.#A.#B.
.#.A#B.
.#.A#.B
.#..#AB
#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+;
char s[N];
int main (){
int n,A,B,C,D;
scanf("%d%d%d%d%d",&n,&A,&B,&C,&D);
scanf("%s",s+);
if( C == D ){
printf("No\n");
}else if( C < D ){
int flag = ;
// if( s[C] == '#' || s[D] == '#' ) flag = 0 ;
for ( int i = A ; i < C ; i++ ){
if ( s[i] == '#' && s[i+] == '#' ){
flag = ;
break ;
}
}
for ( int i = B ; i < D ; i++ ){
if ( s[i] == '#' && s[i+] == '#' ){
flag = ;
break ;
}
}
if( flag ){
printf("Yes\n");
}else{
printf("No\n");
}
}else{
int flag = ;
for ( int i = B ; i < D ; i++ ){
if ( s[i] == '#' && s[i+] == '#' ){
flag = ;
break ;
}
}
for ( int i = A ; i < C ; i++ ){
if (
(s[i] == '#' && s[i+] == '#') ||
(s[i] == '#' && i+ == D ) ||
(s[i+] == '#' && i == D )
){
flag = ;
break ;
}
} int f = ;
for ( int i = B ; i <= D- ; i++ ){
if ( s[i-] == '.' && s[i] == '.' && s[i+] == '.' ){
f = ;
break;
}
}
if( flag || f ){
printf("Yes\n");
}else{
printf("No\n");
}
}
return ;
}
Kenken Race
【思维】Kenken Race的更多相关文章
- 【AtCoder】AGC034
AGC034 刷了那么久AtCoder我发现自己还是只会ABCE(手动再见 A - Kenken Race 大意是一个横列,每个点可以跳一步或者跳两步,每个格子是空地或者石头,要求每一步不能走到石头或 ...
- [C#][算法] 用菜鸟的思维学习算法 -- 马桶排序、冒泡排序和快速排序
用菜鸟的思维学习算法 -- 马桶排序.冒泡排序和快速排序 [博主]反骨仔 [来源]http://www.cnblogs.com/liqingwen/p/4994261.html 目录 马桶排序(令人 ...
- Photoshop、Illustrator思维导图笔记
半年前学习Photoshop时记得的思维导图笔记,可能不是很全,常用的基本都记下了.
- CYQ.Data 从入门到放弃ORM系列:开篇:自动化框架编程思维
前言: 随着CYQ.Data 开始回归免费使用之后,发现用户的情绪越来越激动,为了保持这持续的激动性,让我有了开源的念头. 同时,由于框架经过这5-6年来的不断演进,以前发的早期教程已经太落后了,包括 ...
- 计算机程序的思维逻辑 (8) - char的真正含义
看似简单的char 通过前两节,我们应该对字符和文本的编码和乱码有了一个清晰的认识,但前两节都是与编程语言无关的,我们还是不知道怎么在程序中处理字符和文本. 本节讨论在Java中进行字符处理的基础 - ...
- 计算机程序的思维逻辑 (29) - 剖析String
上节介绍了单个字符的封装类Character,本节介绍字符串类.字符串操作大概是计算机程序中最常见的操作了,Java中表示字符串的类是String,本节就来详细介绍String. 字符串的基本使用是比 ...
- 计算机程序的思维逻辑 (31) - 剖析Arrays
数组是存储多个同类型元素的基本数据结构,数组中的元素在内存连续存放,可以通过数组下标直接定位任意元素,相比我们在后续章节介绍的其他容器,效率非常高. 数组操作是计算机程序中的常见基本操作,Java中有 ...
- 计算机程序的思维逻辑 (33) - Joda-Time
Joda-Time上节介绍了JDK API中的日期和时间类,我们提到了JDK API的一些不足,并提到,实践中有一个广泛使用的日期和时间类库,Joda-Time,本节我们就来介绍Joda-Time.俗 ...
- 计算机程序的思维逻辑 (53) - 剖析Collections - 算法
之前几节介绍了各种具体容器类和抽象容器类,上节我们提到,Java中有一个类Collections,提供了很多针对容器接口的通用功能,这些功能都是以静态方法的方式提供的. 都有哪些功能呢?大概可以分为两 ...
随机推荐
- 前端知识点回顾——mongodb和mongoose模块
mongodb和mongoose模块 数据库 数据库有关系型数据库(MySQL)和非关系型数据库(mongodb),两者的语法和数据存储形式不一样. mySQL 关系型数据库 类似于表格的形式,每一条 ...
- <JavaScript> 普通函数与构造函数的区别
JavaScript中存在构造函数与函数两个概念. 这可能会给初学者造成一定的困扰,难不成存在两种函数. 然而事实这两种函数的构成完全一样,无论从长相还是气质都是一模一样的. 区别点在于,所扮演觉得不 ...
- centos 7 gitlab安装服务器
详情见 https://blog.csdn.net/duyusean/article/details/80011540
- mudos源码分析
错误捕捉相关的代码在simulate.c void throw_error() { )->framekind & FRAME_MASK) == FRAME_CATCH) { LONGJM ...
- MVVM的项目学习和笔记
今天在学习一个用MVVM模式写的项目,掌握一下对MVVM的理解和记的一些笔记. 下面是自己学习的项目链接: http://www.code4app.com/ios/一个MVVM架构的iOS工程/695 ...
- django项目添加路由----返回给客户端内容-----windows中的python
django项目添加路由 url函数的第一个参数是匹配url路径的正则表达式,第2个参数是路由函数 第一个正则表达式是r'^$',其中r表示正则表达式字符串不对转义符进行转义.“^”表示匹配URL路径 ...
- 【leetcode】521. Longest Uncommon Subsequence I
problem 521. Longest Uncommon Subsequence I 最长非共同子序列之一 题意: 两个字符串的情况很少,如果两个字符串相等,那么一定没有非共同子序列,反之,如果两个 ...
- Flutter参数的传递和接收
上次只写了方法和参数,这次写了完整的示例,页面间参数的传递和接收的示例. 1.参数传递 用在程序上解释就是比如你进入一个商品选择列表,当你想选择一个商品的具体信息的时候,你就要传递商品编号,详细页面接 ...
- Day04:循环结构(while、do-while、for)
Java 循环结构 - while ,do...while,for 反复执行一段相同或相似代码的格式. 顺序结构的程序语句只能被执行一次.如果您想要同样的操作执行多次,,就需要使用循环结构. Java ...
- pip install locustio报错
安装locust时, 执行pip install locustio时报错 ERROR: Cannot uninstall 'requests'. It is a distutils installed ...