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. python Flask框架CBV视图

    1.演示之前需要先写一个装饰器 # 装饰器 def wrapper(func): def inner(*args, **kwargs): print('操作函数%s之前' % func.__name_ ...

  2. unknown encoder libvpx

    brew install ffmpeg --with-libvpx or brew reinstall ffmpeg --with-libvpx

  3. 剑指offer 面试3题

    面试3题: 题:数组中重复的数字 题目:在一个长度为n的数组里的所有数字都在0到n-1的范围内. 数组中某些数字是重复的,但不知道有几个数字是重复的.也不知道每个数字重复几次.请找出数组中任意一个重复 ...

  4. 剑指offer 面试38题

    面试38题: 题:字符串的排列 题目:输入一个字符串,按字典序打印出该字符串中字符的所有排列.例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,ca ...

  5. SQL模糊查找

    编辑器加载中... /*********************实现模糊查找**************************/ SELECT [UserId] ,[UserName] ,[User ...

  6. LeetCode:至少是其他数字两倍的最大数【747】

    LeetCode:至少是其他数字两倍的最大数[747] 题目描述 在一个给定的数组nums中,总是存在一个最大元素 . 查找数组中的最大元素是否至少是数组中每个其他数字的两倍. 如果是,则返回最大元素 ...

  7. JavaScript:学习笔记(2)——基本概念与数据类型

    JavaScript:学习笔记(2)——基本概念与数据类型 语法 1.区分大小写.Test 和 test 是完全不同的两个变量. 2.语句最好以分号结束,也就是说不以分号结束也可以. 变量 1.JS的 ...

  8. SVN 过滤文件

    SVN新手最容易犯的一个错误: 就是把所有文件一股脑地全提交上去了. 这样很不好,因为这当中包含很多编译器自动生成的文件,还有中间文件. 这些文件可能每次编译都会不同,所以编译一次就冲突一次. 很显然 ...

  9. Capslock and Esc

    将Caps Lock转换成Esc(windows and linux) 1. linux 下将Caps Lock 转换成Esc 作为一个vimer,Caps Lock对我(还有其他很多人)来说根本就是 ...

  10. 每天一个Linux命令(60)ip命令

        ip命令是Linux下较新的功能强大的网络配置工具.     (1)用法:     用法:  ip  [OPTIONS]  OBJECT  [COMMAND [ARGUMENTS]]     ...