Problem Statement | |||||||||||||
NOTE: This problem statement contains images that may not display properly if viewed outside of the applet. We had a rectangular grid that consisted of W x H square cells. We placed a robot on one of the cells. The robot then followed the rules given below.
![]() We forgot the dimensions of the grid and the original (x,y) coordinates of the cell on which the robot was originally placed, but we do remember its movement. You are given a vector <int> moves. This sequence of positive integers shall be interpreted as follows: The robot performed moves[0] steps eastwards, turned left, performed moves[1] steps northwards, turned left, and so on. After performing the last sequence of steps, the robot stopped. (Either it detected that it should terminate, or we stopped it manually.) We are not sure if the sequence of moves is valid. If the sequence of moves is impossible, return -1. Else, return the minimum area of a grid in which the sequence of moves is possible. (I.e., the return value is the smallest possible value of the product of W and H.). | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | moves will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of moves will be between 1 and 50, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | | ||||||||||||
| |||||||||||||
1) | | ||||||||||||
| |||||||||||||
2) | | ||||||||||||
| |||||||||||||
3) | | ||||||||||||
| |||||||||||||
4) | | ||||||||||||
| |||||||||||||
5) | | ||||||||||||
| |||||||||||||
6) | | ||||||||||||
| |||||||||||||
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.
Problem Statement | |||||||||||||
We have a string originalWord. Each character of originalWord is either 'a' or 'b'. Timmy claims that he can convert it to finalWord using exactly k moves. In each move, he can either change a single 'a' to a 'b', or change a single 'b' to an 'a'. You are given the strings originalWord and finalWord, and the int k. Determine whether Timmy may be telling the truth. If there is a possible sequence of exactly k moves that will turn originalWord into finalWord, return "POSSIBLE" (quotes for clarity). Otherwise, return "IMPOSSIBLE". | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | Timmy may change the same letter multiple times. Each time counts as a different move. | ||||||||||||
Constraints | |||||||||||||
- | originalWord will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | finalWord and originalWord will contain the same number of characters. | ||||||||||||
- | Each character in originalWord and finalWord will be 'a' or 'b'. | ||||||||||||
- | k will be between 1 and 100, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | | ||||||||||||
| |||||||||||||
1) | | ||||||||||||
| |||||||||||||
2) | | ||||||||||||
| |||||||||||||
3) | | ||||||||||||
| |||||||||||||
4) | | ||||||||||||
|
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.
瀛楃涓叉按棰橈紒
249.23PT錛侊紒錛?/p>
Problem Statement | |||||||||||||
You are given a rectangular map in which each space is marked with one of three characters: '.' (open), 'B' (a brick), or '#' (an indestructible block). Walls made of indestructible blocks surround the field on all sides, but are not shown on the map. A ball is bouncing around this map, destroying bricks, and your task is determine how long it takes the ball to destroy all the bricks. The top left space of the map is always open, and this is where the ball begins. More specifically, the ball begins at time 0 in the middle of the top edge of this space (see the diagram in Example 0). The ball is traveling diagonally down and to the right at a speed of half a meter per second vertically, and half a meter per second horizontally. Each space is 1 meter square, so the ball crosses half a space vertically and half a space horizontally each second. Whenever the ball strikes the edge of an obstacle--either a brick or an indestructible block--it bounces off at an angle perpendicular to its incoming path. The ball will never hit two obstacles simultaneously. Whenever the ball bounces off a brick, the brick is destroyed and removed from the map. Your method should return the time at which the last brick is destroyed. If one or more bricks will never be destroyed, return -1. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | map contains between 1 and 15 elements, inclusive. | ||||||||||||
- | All elements of map contain the same number of characters (between 1 and 15, inclusive). | ||||||||||||
- | All elements of map contain only the characters '.', 'B', and '#'. | ||||||||||||
- | The top left corner of map (that is, the first character of the first element) is '.'. | ||||||||||||
- | map contains at least one 'B'. | ||||||||||||
Examples | |||||||||||||
0) | | ||||||||||||
| |||||||||||||
1) | | ||||||||||||
| |||||||||||||
2) | | ||||||||||||
| |||||||||||||
3) | | ||||||||||||
| |||||||||||||
4) | | ||||||||||||
| |||||||||||||
5) | | ||||||||||||
|
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.
Problem Statement | |||||||||||||
The digits 3 and 9 share an interesting property. If you take any multiple of 3 and sum its digits, you get another multiple of 3. For example, 118*3 = 354 and 3+5+4 = 12, which is a multiple of 3. Similarly, if you take any multiple of 9 and sum its digits, you get another multiple of 9. For example, 75*9 = 675 and 6+7+5 = 18, which is a multiple of 9. Call any digit for which this property holds interesting, except for 0 and 1, for which the property holds trivially. A digit that is interesting in one base is not necessarily interesting in another base. For example, 3 is interesting in base 10 but uninteresting in base 5. Given an int base, your task is to return all the interesting digits for that base in increasing order. To determine whether a particular digit is interesting or not, you need not consider all multiples of the digit. You can be certain that, if the property holds for all multiples of the digit with fewer than four digits, then it also holds for multiples with more digits. For example, in base 10, you would not need to consider any multiples greater than 999. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | When base is greater than 10, digits may have a numeric value greater than 9. Because integers are displayed in base 10 by default, do not be alarmed when such digits appear on your screen as more than one decimal digit. For example, one of the interesting digits in base 16 is 15. | ||||||||||||
Constraints | |||||||||||||
- | base is between 3 and 30, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | | ||||||||||||
| |||||||||||||
1) | | ||||||||||||
| |||||||||||||
2) | | ||||||||||||
| |||||||||||||
3) | | ||||||||||||
| |||||||||||||
4) | | ||||||||||||
|
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.
Problem Statement | |||||||||||||
When a widget breaks, it is sent to the widget repair shop, which is capable of repairing at most numPerDay widgets per day. Given a record of the number of widgets that arrive at the shop each morning, your task is to determine how many days the shop must operate to repair all the widgets, not counting any days the shop spends entirely idle. For example, suppose the shop is capable of repairing at most 8 widgets per day, and over a stretch of 5 days, it receives 10, 0, 0, 4, and 20 widgets, respectively. The shop would operate on days 1 and 2, sit idle on day 3, and operate again on days 4 through 7. In total, the shop would operate for 6 days to repair all the widgets. Create a class WidgetRepairs containing a method days that takes a sequence of arrival counts arrivals (of type vector <int>) and an int numPerDay, and calculates the number of days of operation. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | arrivals contains between 1 and 20 elements, inclusive. | ||||||||||||
- | Each element of arrivals is between 0 and 100, inclusive. | ||||||||||||
- | numPerDay is between 1 and 50, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | | ||||||||||||
| |||||||||||||
1) | | ||||||||||||
| |||||||||||||
2) | | ||||||||||||
| |||||||||||||
3) | | ||||||||||||
| |||||||||||||
4) | | ||||||||||||
|
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.
Problem Statement | |||||||||||||
The Order of the Hats is a magical organization. One of their duties is to teach students how to cast spells. There are N spells numbered from 0 to N-1. As an aid for the students, the teachers have prepared a spell chart. The chart lists suggestions on the order in which to study the spells. (This is explained in more detail below.) Recently, some changelings broke into the Order's spell archive and messed up the spell chart. You are given a String[] spellChart containing the new, messed-up state of the spell chart. Each character of each element of spellChart is either 'Y' or 'N'. The students will come to study soon. They will interpret the chart in the following way: If spellChart[i][j] is 'Y' then spell i must be learned before spell j. As the chart is now messed up, it may be impossible to learn all the spells in the chart because of cycles in the requirements. Your task is to repair the given chart. Determine the minimum number of changes needed to remove all the cycles in the requirements. In a single change, you may either change some character spellChart[i][j] from 'Y' to 'N', or change some character from 'N' to 'Y'. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | spellChart will contain between 1 and 20 elements, inclusive. | ||||||||||||
- | Each element of spellChart will contain N characters, where N is the number of elements in spellChart. | ||||||||||||
- | Each character in each element of spellChart will be either 'Y' or 'N'. | ||||||||||||
Examples | |||||||||||||
0) | | ||||||||||||
| |||||||||||||
1) | | ||||||||||||
| |||||||||||||
2) | | ||||||||||||
| |||||||||||||
3) | | ||||||||||||
| |||||||||||||
4) | | ||||||||||||
| |||||||||||||
5) | | ||||||||||||
| |||||||||||||
6) | | ||||||||||||
| |||||||||||||
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.
Problem Statement | |||||||||||||
The Order of All Things Pointy and Magical has commissioned the creation of some new wizard hats. A wizard hat is created by taking two cones: a decorative top cone, and a warm and fluffy bottom cone. To assemble the hat, both cones are first placed onto a table, so that their bases are horizontal and their apexes point upwards. The top cone is then lifted and placed onto the bottom cone. The base of the top cone has to remain horizontal, and the apex of the top cone must be strictly above the apex of the bottom cone. Not every pair of cones can be used to create a wizard hat. A wizard hat is only produced if the following two criteria are both met:
Your task is to determine the maximum number of wizard hats you can make using each of the available top and bottom cones at most once. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | topHeight and topRadius will contain the same number of elements. | ||||||||||||
- | bottomHeight and bottomRadius will contain the same number of elements. | ||||||||||||
- | topHeight will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | topRadius will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | bottomHeight will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | bottomRadius will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of topHeight, topRadius, bottomHeight, and bottomRadius will be between 1 and 10,000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | | ||||||||||||
| |||||||||||||
1) | | ||||||||||||
| |||||||||||||
2) | | ||||||||||||
| |||||||||||||
3) | | ||||||||||||
| |||||||||||||
4) | | ||||||||||||
| |||||||||||||
5) | | ||||||||||||
| |||||||||||||
6) | | ||||||||||||
| |||||||||||||
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.
|
Problem Statement | |||||||||||||
A magician has invited you to play a game. For this game, the magician uses a special table. On the table there are three spots in a row. The spots are labeled 0, 1, and 2, in order. He places three hats onto the table, so that each hat covers one of the spots. He then takes a ball and places it under one of the hats. The hats are not transparent, so you cannot see the ball while it is under a hat. Next, the magician shuffles the hats by repeatedly swapping two adjacent hats. Each swap is done by sliding the hats along the table, never showing you the ball. Once the magician finishes swapping the hats, you have to guess the spot where the ball is. You are given a string hats which describes the contents of the hats in the beginning of the game. The i-th character of hats is 'o' if the ball was initially on the spot i. Otherwise, the i-th character of hats is '.' (a period). You are also given a int numSwaps. Assume that the magician swapped the hat that contained the ball exactly numSwaps times. Please remember that in our version of the game the magician always swaps two adjacent hats. Also, note that the total number of swaps in the game may be larger than numSwaps, because the magician may sometimes swap two hats that don't contain the ball. Assume that the magician chose the swaps he makes uniformly at random. That is, in each turn with probability 50% he swapped the hats on spots 0 and 1, and with probability 50% he swapped the hats on spots 1 and 2. Return the number of the spot that is most likely to contain the ball at the end of the game. If multiple spots are tied for the largest probability, return the smallest one of them. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | Two hats are adjacent if their spots differ by 1. | ||||||||||||
Constraints | |||||||||||||
- | hats will contain exactly three characters. | ||||||||||||
- | hats will contain exactly one 'o' character. | ||||||||||||
- | hats will contain exactly two '.' characters. | ||||||||||||
- | numSwaps will be between 0 and 1000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | | ||||||||||||
| |||||||||||||
1) | | ||||||||||||
| |||||||||||||
2) | | ||||||||||||
| |||||||||||||
3) | | ||||||||||||
| |||||||||||||
4) | | ||||||||||||
|
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.