SRM 146 DIV1 800
Problem Statement |
|||||||||||||
The purpose of a roundabout is to control the flow of traffic at a busy intersection. A roundabout has 4 entry points: from the North, East, South and West; and 4 exit points at the same locations (see Example 0 for a diagram). Cars can enter, leave or move one position on the roundabout. Each of those events requires one second. All the events can take place simultaneously. So if there are two cars on the roundabout, one behind the other, then they can both move during the next second. A car decides whether to enter the roundabout based on its knowledge from the previous second. A car will always enter if it has the right to do so. A car has the right to enter only if there are no cars to its immediate left (either on the roundabout or waiting to get on the roundabout) and it is the first car in line at the entry point (Example 1 demonstrates this). A special case occurs if there is a car at each of the 4 entry points. In this case, the car from the North will wait until there are no cars to its left on the roundabout and then will be the first to enter. Once the car is on the roundabout, it moves counter-clockwise until it exits the roundabout. There are 4 positions on the roundabout. So for example, it would take 1 second to enter the roundabout, 2 seconds to complete half a lap and another 1 second to exit the roundabout. Each parameter of the input is a second by second account of cars coming from that direction with their intended exit locations. Intended exit locations will be N (North), E (East), S (South) and W (West). A '-' means that no car arrived during that second at the given entry point. Thus, for example, character i of north represents the direction in which a car (if there is one) arriving from the north at time i will leave the roundabout. So, at time i, this car will be added to the end of the line at the north entry point to the roundabout. Cars will not be allowed to exit the roundabout at the point of their entry. Given the lists of cars coming from the 4 directions, return the total time required for all cars to leave the roundabout. |
|||||||||||||
Definition |
|||||||||||||
|
|||||||||||||
Limits |
|||||||||||||
|
|||||||||||||
Constraints |
|||||||||||||
- | north, east, south and west will contain between 0 and 50 characters inclusive. | ||||||||||||
- | north, east, south and west must only contain 'N', 'W', 'S', 'E' and '-' characters. | ||||||||||||
- | north will NOT contain the character 'N'. | ||||||||||||
- | east will NOT contain the character 'E'. | ||||||||||||
- | south will NOT contain the character 'S'. | ||||||||||||
- | west will NOT contain the character 'W'. | ||||||||||||
Examples |
|||||||||||||
0) | |||||||||||||
|
|||||||||||||
1) | |||||||||||||
|
|||||||||||||
2) | |||||||||||||
|
|||||||||||||
3) | |||||||||||||
|
|||||||||||||
4) | |||||||||||||
|
|||||||||||||
5) | |||||||||||||
|
|||||||||||||
6) | |||||||||||||
|
|||||||||||||
7) | |||||||||||||
|
|||||||||||||
8) | |||||||||||||
|
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
SRM 146 DIV1 800的更多相关文章
- SRM 146 DIV1 600
Problem Statement Masterbrain is a two player board game in which one player decides on a secre ...
- Topcoder SRM 643 Div1 250<peter_pan>
Topcoder SRM 643 Div1 250 Problem 给一个整数N,再给一个vector<long long>v; N可以表示成若干个素数的乘积,N=p0*p1*p2*... ...
- Topcoder Srm 726 Div1 Hard
Topcoder Srm 726 Div1 Hard 解题思路: 问题可以看做一个二分图,左边一个点向右边一段区间连边,匹配了左边一个点就能获得对应的权值,最大化所得到的权值的和. 然后可以证明一个结 ...
- 图论 SRM 674 Div1 VampireTree 250
Problem Statement You are a genealogist specializing in family trees of vampires. Vampire famil ...
- SRM 583 DIV1
A 裸最短路. class TravelOnMars { public: int minTimes(vector <int>, int, int); }; vector<int> ...
- SRM 590 DIV1
转载请注明出处,谢谢viewmode=contents">http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlov ...
- Topcoder SRM 602 div1题解
打卡- Easy(250pts): 题目大意:rating2200及以上和2200以下的颜色是不一样的(我就是属于那个颜色比较菜的),有个人初始rating为X,然后每一场比赛他的rating如果增加 ...
- 状态压缩DP SRM 667 Div1 OrderOfOperations 250
Problem Statement Cat Noku has just finished writing his first computer program. Noku's compute ...
- 数学 SRM 690 Div1 WolfCardGame 300
Problem Statement Wolf Sothe and Cat Snuke are playing a card game. The game is played with exa ...
随机推荐
- Hibernate5.2之多对多关联关系(六)
Hibernate5.2之多对多关联关系(六) 一.简介 Hibernate中多对多关联关系在工程中使用的频率也是非常高的,例如:大学中学生选课.用户订单等.在本博客中笔者一样通过实例代码为读者阐述H ...
- 关于Maven项目
用maven 工程搭建项目,在搭建好之后,运行时却抛出了这样的错误: Error configuring application listener of class org.springframew ...
- Django 之 分表
app名称为'core',基本的models.py文件内容如下: class Province(models.Model): name = models.CharField(u'省份名称',max_l ...
- 使用百度地图API产生指定范围的随机点
直接上代码: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...
- Redis 配置文件
# Redis configuration file example. # # Note that in order to read the configuration file, Redis mus ...
- 工作流软件是未来web的支柱
Web 3.0正在敲门,但是开门的人你永远都想不到:工作流软件. 传统上工作流软件是企业级的业务流程管理工具,但现在随着网络互联程度的加深,工作流软件开始呈现出其作为互联网技术的一面. 诚然,社会化媒 ...
- linux 网络编程比较好的文章
讲解epoll的, 算是比较详细的. 直接看使用部分就行. http://blog.csdn.net/xiajun07061225/article/details/9250579
- 怎样安装Ubuntu操作系统
(转载自:http://jingyan.baidu.com/article/ff42efa9423991c19e22020d.html) 准备工作 1. 一台普通电脑(装没装操作系统无所谓),保证电脑 ...
- ADC测试matlab代码
前面有做过ADC性能测试,测试方式是先使用ADC采集一个单频信号,然后利用matlab进行性能分析. 下面把matlab分析的代码记录下来: %The following program code p ...
- BCP
转:(总结) SQL Server Bulk Insert 批量数据导入 DB SQL ServerBulk InsertBCPOPENROWSET格式文件 SQL Server的Bulk Inser ...