2020. Traffic Jam in Flower Town

Time limit: 1.0 second
Memory limit: 64 MB
Having returned from Sun City, Dunno told all his friends that every shorty may have a personal automobile. Immediately after that so many citizens took a fancy of becoming road-users, that Bendum and Twistum had to make a mass production of cars on soda water with syrup. Now traffic jams from several cars occasionally appear on the crossing of Bell-flower Street and Daisy Street.
Bell-flower Street goes from the South to the North and has two driving paths. It has the right driving, i. e. automobiles move from the South to the North on the Eastern path and from the North to the South on the Western path. Daisy Street is single-pathed, and it is perpendicular to Bell-flower Street. There is one-way movement on it, but its driving direction is organized in such a way that automobiles drive away from the crossroad in two opposite directions (see the picture).

Yesterday on his way home Dunno saw cars standing in a traffic jam on Bell-flower Street from different sides of the crossing with Daisy Street. Some of the drivers wanted to go forward, some wanted to turn right or left. An automobile can pass the crossing in one second, but if the driver is turning left, he first have to let pass all oncoming vehicles, going forward and to the right. How many seconds did it take all the cars to pass the crossing, providing that no other cars drove up to the crossing?

Input

The first line contains the sequence of symbols “F”, “L” and “R”, describing directions in which drivers who arrived to the crossing from the South wanted to go. “F” stands for those drivers who were going forward, “L” is for those who were turning left, and “R” is for those who were turning right. Automobiles are listed in the order from the closest to the crossing to the farthest one. The second line contains the description of the cars, arrived to the crossing from the North, in the same form. Both sequences have length from 1 to 1 000.

Output

Output time in seconds, which took all the cars to pass the crossing.

Samples

input output
RLF
FF
4
L
L
1

Notes

In the first example we number the cars from 1 to 5 in the order described in the input data. Then in the first second the crossing was passed by the first and the fourth cars because they didn’t cause an obstruction to each other. Then the second car was turning left and had to let the fifth car pass. As a result, at each of the following three seconds only one car passed the crossing, and their order was as follows: the fifth one, the second one and the third one.
In the second example the cars didn’t cause any obstruction to each other and turned simultaneously.
Problem Author: Denis Dublennykh (prepared by Nick Burlakov)
Problem Source: NEERC 2014, Eastern subregional contest
 
 
 
模拟,
 #include <bits/stdc++.h>
using namespace std;
char ch1[+],ch2[+];
int main ()
{
int n;
while(~scanf("%s%s",ch1,ch2))
{
int pnt1=,pnt2=;
int len1=strlen(ch1),len2=strlen(ch2);
int sum=;
while(pnt1!=len1&&pnt2!=len2){
if(ch1[pnt1]=='L'&&(ch2[pnt2]=='F'||ch2[pnt2]=='R')){
pnt2++;
}else if((ch1[pnt1]=='F'||ch1[pnt1]=='R')&&ch2[pnt2]=='L'){
pnt1++;
}else{
pnt1++,pnt2++;
}
sum++;
}
while(pnt1!=len1)
sum++,pnt1++;
while(pnt2!=len2)
sum++,pnt2++;
printf("%d\n",sum);
}
return ;
}
 

ural 2020 Traffic Jam in Flower Town(模拟)的更多相关文章

  1. Gym 100507I Traffic Jam in Flower Town (模拟)

    Traffic Jam in Flower Town 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/I Description ...

  2. 2020.10.20 利用POST请求模拟登录知乎

    前两天学习了Python的requests模块的相关内容,对于用GET和PSOT请求访问网页以抓取需要的内容有了初步的了解,想要再从一些复杂的网站积累些经验.最开始我采用最简单的get(url)方法想 ...

  3. JAM计数法(模拟)

    题目描述 Jam是个喜欢标新立异的科学怪人.他不使用阿拉伯数字计数,而是使用小写英文字母计数,他觉得这样做,会使世界更加丰富多彩.在他的计数法中,每个数字的位数都是相同的(使用相同个数的字母),英文字 ...

  4. 【初赛】CSP 2020 第一轮(初赛)模拟记录

    感觉初赛不过关,洛谷上找了一套没做过的来练习. 顺便写了详细的题解. 试题用时:1h 单项选择: 第 1 题 十进制数 114 的相反数的 8 位二进制补码是: A.10001110 B.100011 ...

  5. Round 1A 2020 - Code Jam 2020

    Problem A. Pattern Matching 把每个字符串分成第一个之前,最后一个之后,中间的部分 三个部分 每个字符串的中间的部分可以直接拼接 前后两个部分需要判断下是否合法 #inclu ...

  6. UVALive 2664 One-way traffic

    One-way traffic Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Or ...

  7. LightOJ 1291 Real Life Traffic

    Real Life Traffic Time Limit: 2000ms Memory Limit: 32768KB This problem will be judged on LightOJ. O ...

  8. Java实现One-way traffic(单向交通)

    One-way traffic In a certain town there are n intersections connected by two- and one-way streets. T ...

  9. <老友记>学习笔记

    这是六个人的故事,从不服输而又有强烈控制欲的monica,未经世事的千金大小姐rachel,正直又专情的ross,幽默风趣的chandle,古怪迷人的phoebe,花心天真的joey——六个好友之间的 ...

随机推荐

  1. Python3 面向对象(1)

    面向.概述 面向过程: 根据业务逻辑从上到下写垒代码面向过程的设计的核心是过程,过程即解决问题的步骤, 面向过程的设计就好比精心设计好一条流水线,考虑周全什么时候处理什么东西 优点: 极大降低了程序的 ...

  2. Python3.6全栈开发实例[011]

    11.元素分类有如下值li= [11,22,33,44,55,66,77,88,99,90],将所有大于 66 的值保存至字典的第一个key中,将小于 66 的值保存至第二个key的值中.即: {'k ...

  3. 爬虫五 Beautifulsoup模块

    一 介绍 Beautiful Soup 是一个可以从HTML或XML文件中提取数据的Python库.它能够通过你喜欢的转换器实现惯用的文档导航,查找,修改文档的方式.Beautiful Soup会帮你 ...

  4. jquery datepicker日历控件

    地址:http://jqueryui.com/datepicker/ 使用:$( "#datepicker" ).datepicker(); $.datepicker.setDef ...

  5. [笔记]Go语言在Linux环境下输出彩色字符

    Go语言要打印彩色字符与Linux终端输出彩色字符类似,以黑色背景高亮绿色字体为例: fmt.Printf("\n %c[1;40;32m%s%c[0m\n\n", 0x1B, & ...

  6. ASP.NET 4.0 ListView等容器控件中获取ClientID值与HTML中自动生成ID字符串不一样问题。

    ASP.NET 4.0 中 ClientIDMode的属性 可以设置获取不同ID格式的值. 项目中遇到的问题: 1.ListView1 ItemDataBound事件中,获取ClientID结果与自动 ...

  7. $SublimeText2常用快捷键

    1.删除一行:ctrl + shift + K2.替换:ctrl + H3.设置书签:Ctrl+F2设置书签F2 下一个书签Shift+F2上一个书签4.查找:ctrl + F 查找F3 查找下一个s ...

  8. springboot获取URL请求参数的几种方法

    原文地址:http://www.cnblogs.com/xiaoxi/p/5695783.html 1.直接把表单的参数写在Controller相应的方法的形参中,适用于get方式提交,不适用于pos ...

  9. php任务管理器 —— Jobby

    通过一个主crontab任务去维护别的任务 自定义的计划任务完全由PHP编写 任务的执行计划时间表设置与crontab的时间表设置语法一致 在指定的时间内只会运行一个任务 邮件告警异常退出任务 在ro ...

  10. mybatis使用注意的细节

    1.mybatis对sql执行后会对结果进行封装,如果没有返回任何记录,只是封装后的对象没有值,而对象并不为空null: (这个问题疏忽坑了两次,在对返回数组结果进行判断的时候,我用的if(Array ...