월요일 저녁 9시에 열린 매치.. 2010 년 첫 SRM 이다..
250 점 문제에서 딱 하나의 케이스를 생각 못해서 챌 당했다.. 젠장
이번엔 시간대가 좋아서 한국사람이 많이 참가했다..
이제 앞으로는 다 새벽시간인데.. 흠.. 이거 연초부터 하기 싫어지는데..
Level1 - TheTriangleBothDivs
Problem Statement
John and Brus have always been confused by time zones. Their recent promotions to Concorde pilot and copilot do not help. Having to constantly fly through the Bermuda Triangle does not help either. They have therefore purchased a special digital clock that displays the current time in one of 19 time zones, from GMT-9 to GMT+9. The clock displays time in the format "HH:mm GMTof" (quotes for clarity), where HH is the hour of the day (between 00 and 23, inclusive), mm is the number of minutes since the start of the hour (between 00 and 59, inclusive), and of is the offset from "Greenwich Mean Time" (time zone GMT+0) to the current time zone. If the offset is +4, for example, it means the displayed time is 4 hours ahead of the time in GMT+0, and if the offset is -4, it means the time is 4 hours behind the time in GMT+0. GMT+0 will always be displayed with an offset of +0, so the clock will never display it as GMT-0. In the middle of a flight, John wanted to know what time it was, so he asked Brus to check the clock. To Brus' surprise, the Bermuda Triangle had caused the clock to malfunction, and some of the characters on the display were unrecognizable. You are given the clock's display as a string time, where '?' characters represent the unrecognizable characters. Assuming that all the recognizable characters are accurate, determine what time it is in time zone GMT+0. Return this time formatted as "HH:mm" (quotes for clarity). If there are multiple possible answers, return the one that comes earliest lexicographically. The constraints ensure that at least one result is always possible.
Definition
Class:
TheTriangleBothDivs
Method:
fix
Parameters:
string
Returns:
string
Method signature:
string fix(string time)
(be sure your method is public)
Notes
-
string s1 comes before string s2 lexicographically if s1 has a lexicographically smaller character at the first index where they differ.
Constraints
-
time will contain exactly 11 characters.
-
time will be formatted "xx:xx GMTsx" (quotes for clarity).
-
Each x in time will be a digit ('0'-'9') or '?'.
-
The s in time will be '-','+' or '?'.
-
time will represent a valid clock display (as described in the statement) where zero or more of the digits or the '-' or '+' sign have been replaced by '?' characters.
Examples
0)
"17:45 GMT-4"
Returns: "21:45"
1)
"16:?? GMT??"
Returns: "00:00"
There are many possible times the clock could be displaying, for example: "16:00 GMT+8", "16:35 GMT-9", etc. It is possible to choose "00" minutes and the GMT-8 time zone to yield time "00:00" which is the lexicographically first result.
2)
"?1:34 GMT-9"
Returns: "06:34"
3)
"??:?? GMT??"
Returns: "00:00"
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.
? 위치에 임의의 숫자가 들어올 수 있을때.. GMT+0 으로 고쳤을때 가장 빠른시간으로 가능한 시간 구하기..
너무 우습게 보다가 틀린 문제이다..
마땅히 좋은 방법이 생각이 안나서 그냥 backtracking 으로 모든 숫자를 다 넣어보았다..
문제가 되는 경우가.. "12:00 GMT-?" 같은 경우 문제 조건에 따라서 답은 13:00 이 된다..
이 경우를 놓쳐서 나를 비롯하여 많은 사람이 챌 당하였음.. 젠장
John and Brus are interested in a new game called "Hexagon Flower". The rules are simple. You are given a flower formed by seven hexagons arranged as follows:
The objective of the game is to place a number in each hexagon of the flower such that all of the following conditions are satisfied:
Each number is an integer between 1 and n*2, inclusive.
Each number is distinct.
For every pair of adjacent hexagons, if the numbers placed in them are a and b, then a%n != b%n.
Given n, return the total number of distinct solutions. Two solutions are considered the same if you can rotate one to form the other. For example, if n = 4 then:
The top three placements are not valid. The other three placements are valid, but the first two among them are considered equal since one can be rotated to become the other.
Definition
Class:
TheHexagonsDivOne
Method:
count
Parameters:
int
Returns:
long long
Method signature:
long long count(int n)
(be sure your method is public)
Constraints
-
n will be between 1 and 150, inclusive.
Examples
0)
3
Returns: 0
There are not enough numbers to fill the flower with.
1)
4
Returns: 256
2)
8
Returns: 3458560
3)
20
Returns: 11193888000
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.
to be updated..
Level3 - TheSquareDivOne
Problem Statement
John and Brus like puzzles. They have been playing a new game which involves placing checkers on a square board. The board is a grid containing the same number of columns and rows. The game begins with John placing checkers on specific cells of the board. Then, R[i] is calculated for each row i, where R[i] is the number of checkers in the i-th row. Brus must then move the checkers in such a way that for each column i in the final board, the number of checkers in that column is equal to R[i]. Note that R[i] is calculated for the initial placement of checkers and is not modified afterwards. In a single turn, Brus can move a checker up, down, left or right into an adjacent empty cell. He must use as few turns as possible to reach the goal. You are give a vector <string> board, where the j-th character of the i-th element is uppercase 'C' if the cell at row i, column j contains a checker and '.' otherwise. Return the final placement of checkers using the same format as the input. Since there may be many possible final placements, return the one that comes first lexicographically.
Definition
Notes
-
The lexicographically earlier of two vector <string>s is the one that has the lexicographically earlier string in the first position at which they differ.
-
The lexicographically earlier of two strings is the one that has the earlier character (using ASCII ordering) at the first position at which they differ.
-
In ASCII ordering, a dot character '.' comes before 'C'.
Constraints
-
board will contain exactly n elements, where n is between 1 and 18, inclusive.
-
Each element of board will contain exactly n characters.
-
Each element of board will contain only uppercase 'C' or '.'.
Examples
0)
{"...",
"...",
"C.."}
Returns: {"...", "...", "..C" }
Initially, R[0] = 0, R[1] = 0, R[2] = 1. There is currently a checker in column 0 which must be moved to column 2. It can be done in two turns.
1)
{"CCC",
".C.",
"CCC"}
Returns: {"C.C", "C.C", "CCC" }
CCC CCC C.C C.C
.C. -> ..C -> .CC -> C.C
CCC CCC CCC CCC
The following sequence also takes three turns, but its final placement does not come earlier lexicographically:
CCC CCC CCC CCC
.C. -> C.. -> CC. -> C.C
CCC CCC C.C C.C
2)
{"C..",
".C.",
"..C"}
Returns: {"C..", ".C.", "..C" }
No move is necessary.
3)
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.