[转]Google中国编程挑战赛
来源:互联网 发布:linux种类 编辑:程序博客网 时间:2024/05/01 03:35
晚上和小侯一起上去参加预选赛,结果就不出意外的受打击了,我在65分钟的时候完整的作出来了两道题目中的一个(还是250分的,750分的那个没来得及看)。不幸的是,考试时间是一个小时,也就是说我交上去的是个不怎么正确的,得到的是可怜的90来分。这是我所在组的排行榜,强人真是多的很哪!!
受打击了,整天喊着好好学习天天向上,也不知道自己到底学到了什么,真是对不起毛主席他老人家。贴出我做的那一题目,仅作立此存照意。
Problem Statement
You are given a String[] cityMap representing the layout of a city. The city consists of blocks. The first element of cityMap represents the first row of blocks, etc. A 'B' character indicates a location where there is a bus stop. There will be exactly one 'X' character, indicating your location. All other characters will be '.'. You are also given an int walkingDistance, which is the maximum distance you are willing to walk to a bus stop. The distance should be calculated as the number of blocks vertically plus the number of blocks horizontally. Return the number of bus stops that are within walking distance of your current location.
Definition
Class:
BusStops
Method:
countStops
Parameters:
String[], int
Returns:
int
Method signature:
int countStops(String[] cityMap, int walkingDistance)
(be sure your method is public)
Constraints
-
cityMap will contain between 1 and 50 elements, inclusive.
-
Each element of cityMap will contain between 1 and 50 characters, inclusive.
-
Each element of cityMap will contain the same number of characters.
-
Each character of each element of cityMap will be 'B', 'X', or '.'.
-
There will be exactly one 'X' character in cityMap.
-
walkingDistance will be between 1 and 100, inclusive.
Examples
0)
{"...B.",
".....",
"..X.B",
".....",
"B...."}
3
Returns: 2
You can reach the bus stop at the top (3 units away), or on the right (2 units away). The one in the lower left is 4 units away, which is too far.
1)
{"B.B..",
".....",
"B....",
".....",
"....X"}
8
Returns: 3
A distance of 8 can get us anywhere on the map, so we can reach all 3 bus stops.
2)
{"BBBBB",
"BB.BB",
"B.X.B",
"BB.BB",
"BBBBB"}
1
Returns: 0
Plenty of bus stops, but unfortunately we cannot reach any of them.
3)
{"B..B..",
".B...B",
"..B...",
"..B.X.",
"B.B.B.",
".B.B.B"}
3
Returns: 7
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.
- [转]Google中国编程挑战赛
- google中国编程挑战赛题目
- Google中国编程挑战赛第一轮
- google中国编程挑战赛题目FillBaskets
- Google中国编程挑战赛-题目解答
- Google中国编程挑战赛-题目解答
- Google中国编程挑战赛一窥
- Google™ Code Jam - 中国编程挑战赛
- 浅尝 Google™ Code Jam - 中国编程挑战赛
- Google™ Code Jam - 中国编程挑战赛模拟题一
- Google™ Code Jam - 中国编程挑战赛模拟题二
- Google™ Code Jam - 中国编程挑战赛模拟题三
- Google中国编程挑战赛第一轮Room18第二题
- google中国编程挑战赛资格赛真题 -- SkipStones
- google中国编程挑战赛资格赛真题 -- PlayCards
- google 编程挑战赛(1)
- google 编程挑战赛(2)
- google 编程挑战赛(3)
- 测试时代
- [转]男人感悟100条,值得一读!
- 一款系统的短暂生命
- Oracle真正的应用集群(RAC)
- 失恋物语
- [转]Google中国编程挑战赛
- Oracle认证基本知识介绍
- 犯罪代价
- 网络无障碍简介
- 一段经典的c 分析6
- 记录下 12 15 2005
- Google搜索原理论文(转)
- 用CSS创建不同分辩率下居中的页面
- BASH脚本编写教程[ZZ]