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 ...
随机推荐
- 文章汇总(包括NVMe SPDK vSAN Ceph xfs等)
基础部分 NVMe驱动解析-前言 NVMe驱动解析-注册设备 NVMe驱动解析-关键的BAR空间 NVMe驱动解析-DMA传输(热门) NVMe驱动解析-响应I/O请求 用一个简单的例子窥探NVMe的 ...
- [I2C]I2C架构分析
转自:http://blog.csdn.net/wangpengqi/article/details/17711165 1. I2C 概述 I2C是philips提出的外设总线. I2C只有两条线,一 ...
- maven 项目无法发布,无法编译的解决办法
1 Web Deployment Assembly信息都合理2 重新clear项目,让JAVA代码重新生成.class文件在target目录中
- 使用Java的Timer处理周期性任务
package timer; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; ...
- [Linux] 关于Centos6中ulimit nproc用户进程数的限制
一.缘由: 在启动mongodb的时候,有Warning提示soft rlimits too low,就是用户使用进程数过小,遂调高系统资源关于用户最大进程数的限制ulimit -u. 先暂时使设置生 ...
- javascript网址收集
1.模块的写法http://www.ruanyifeng.com/blog/2012/10/javascript_module.html 2.模块规范 AMDhttp://www.ruanyifeng ...
- JVM/JDK/JRE/IDE—区别(很经典)
转载于 http://blog.csdn.net/jojo52013145/article/details/5801916 只是为了学习,转载没有别的目地,就是爱copy,copy一点点,进步一点点 ...
- [AS3.0] Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.解决办法
在运用FMS录制视频时,假如出现这个错误,最直接的解决办法如下: _netConnection.client = { onBWDone: function():void{ trace("on ...
- html-tab page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- 64位电脑上配置mysql-connector-odbc的方法
在系统盘搜索odbcad32,选择在C:\Windows\SysWOW64内的文件
