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. qs.parse()、qs.stringify()、JSON.stringify() 用法及区别

    在处理数据的时候,有时候我们需要将对象和字符串和json之间进行转换,这个时候我们可以使用以下的方法 qs是一个npm仓库所管理的包,可通过npm install qs命令进行安装. qs.strin ...

  2. Hard模式学编程

    靖难: 我一直推崇一种学习编程的方法,就是learn programming the hard way,我把它翻译为Hard模式学编程 . 我觉得他有以下几个要领: 1. 一开始学习的时候,要尽量去化 ...

  3. 【jenkins】jenkins实时显示python脚本输出

    jenkins在构建shell脚本时可以实时输出结果,但是在构建python脚本时,是等到python执行完成以后,才显示结果,这个对于我们判断脚本执行状态非常不利 这里介绍一种方法,能够实时显示py ...

  4. 面向对象编程——super进阶(十)

    一.入门使用 在python中,使用super最常见的让子类继承父类.在这种情况下,当前类和对象可以作为super函数的参数使用,调用函数返回的任何方法都是调用超类的方法,而不是当前类的方法. cla ...

  5. 备注字段长度控制JS

    //变更原因备注字符长度控制 function checkChangeLength() { var field = $("#changeReasonDesc").val(); ma ...

  6. 极速Node.js:来自LinkedIn的10个性能提升秘籍

    from:http://faylai.iteye.com/blog/1293194 1.避免使用同步的方法 nodejs 是基于单线程.为了让单线程能够处理高并发的请求,我们尽量要避免让线程等待,阻塞 ...

  7. tar软件安装

    安装tar   ./configure   make   sudo make install

  8. 缓存:Memcached Redis

    一.Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的 ...

  9. Funq之Lambda表达式2

    Last month I started a series of posts covering some of the new VB and C# language features that are ...

  10. Safari通过JavaScript获取系统语言

      IE6 IE7 IE8 Firefox Chrome Safari Opera navigator.language undefined zh-CN zh-CN navigator.userLan ...