URAL 2020. Traffic Jam in Flower Town
来源:互联网 发布:sportman足球分析软件 编辑:程序博客网 时间:2024/05/23 14:32
2020. Traffic Jam in Flower Town
Time limit: 1.0 second
Memory limit: 64 MB
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
RLFFF
4
LL
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
Problem Source: NEERC 2014, Eastern subregional contest
Tags: none
交通常识 左拐躲右拐的和直行的
这题不是我敲的
两串同时遍历
)交通常识 左拐躲右拐的和直行的
这题不是我敲的
两串同时遍历
#include<stdio.h>#include<string.h>int main(){ int sum = 0; char a[1500], b[1500]; int i, j, l1, l2; scanf("%s", a); scanf("%s", b); l1 = strlen(a); l2 = strlen(b); i = 0; j = 0; while(i < l1 && j < l2) { if(a[i] != 'L' && b[j]!='L') { i++; j++; sum++; } else if(a[i] == 'L' && b[j] == 'L') { i++; j++; sum++; } else if(a[i] == 'L' && b[j]!='L') { j++; sum++; } else if(a[i]!= 'L' && b[j] == 'L') { i++; sum++; } } while(i<l1) { i++; sum++; } while(j<l2) { j++; sum++; } printf("%d\n", sum); return 0;}
0 0
- URAL 2020. Traffic Jam in Flower Town
- URAL 2020. Traffic Jam in Flower Town(模拟)
- URAL2020 Traffic Jam in Flower Town (模拟)
- poj1817 Traffic Jam
- Traffic Jam UVA
- 【codechef】Traffic jam for N5
- LA 4082 Traffic Jam (分块)
- 搜索 HOJ 1838 Traffic Jam
- POJ 1817 Traffic Jam 笔记
- Zball in Tina Town
- Zball in Tina Town
- hdu5391Zball in Tina Town
- 交通拥堵费 traffic jam fee
- HDU5391-Zball in Tina Town
- hdu5393 Falsyta in Tina Town
- hdu5391 Zball in Tina Town
- Infoplane in Tina Town HDU
- Zball in Tina Town HDU
- Android fragment 与Activity 互相传值。
- BZOJ 2460 [贪心][线性基]
- C语言学生信息管理系统(动态链表版)
- Retrofit实战(一)一个简单的示例
- 写篇英语总结
- URAL 2020. Traffic Jam in Flower Town
- 大型分布式网站的分布式缓存
- 数据结构与算法(13)——队列
- GDB学习笔记(一)--常用命令
- python正则表达式
- BZOJ 2648 SJY摆棋子
- PAT1009. 说反话 (20)
- [idea] 编译报错 javacTask:源发行版1.8 需要目标发行版1.8
- JAVA 事务之JDBC事务、JTA事务和容器事务