Time Limit: 1 second
Troy and JP are big hockey fans. Every hockey team played
Troy’s favourite team is the Waterloo Geese and he recorded the
outcome of all their games as a string W
if the Geese won their L
if the Geese lost
their
JP’s favourite team is the Laurier Hawks and he recorded the outcome
of all their games as a string W
if the Hawks
won their L
if the Hawks
lost their
Troy and JP recorded wins/losses and points in the order that their favourite teams played.
A rivalry game is one where the Geese and Hawks played each other. Since neither Troy or JP recorded the opponents their favourite teams faced, they are not sure which games, if any, were rivalry games. They wonder what is the maximum possible sum of points scored by both their teams in rivalry games that matches the information they recorded.
The first line contains one integer
The second line contains string W
and L
.
The third line contains
The fourth line contains string W
and L
.
The fifth line contains
For
Print one line with one integer, the maximum possible sum of points scored in potential rivalry games.
1
W
2
W
3
0
Since both the Geese and Hawks won all their games, there could not have been any rivalry games.
4
WLLW
1 2 3 4
LWWL
6 5 3 2
14
The fourth game each team played could have been a rivalry game where
Geese won with
Note that the first game played by the Geese was a win where they scored 1 goal: this game cannot be against the Hawks, since there is no game where the Hawks scored 0 goals. Similarly, the first game played by the Hawks cannot be used, since the Hawks lost and scored 6 goals, and the Geese never had a game where they scored at least 7 goals.
Time Limit: 1 second
Troy made the following problem (titled WA) for a programming contest:
There is a game with
JP is a contestant and submitted the following Python solution.
def Solve(N, A):
# A[i][j] is cost of moving from level i to level j
# N is the number of levels
x, y, sx, sy = 1, 1, 0, 0 # Initialize x and y to 1, sx and sy to 0
for i in range(2, N + 1): # loop from 2 to N
if sx + A[x][i] < sy + A[y][i]:
sx += A[x][i]
x = i
else:
sy += A[y][i]
y = i
return sx + sy
Troy is certain that JP’s solution is wrong. Suppose for an input to
WA, JP’s solution returns
There is no input.
Print an input to WA in the following format:
On the first line, print one integer
Then print
If your output is not the correct format, it will get an incorrect verdict on the sample test in the grader and score 0 points.
Otherwise, suppose that for your input, JP’s solution returns
5
1 2 3 4
10 9 8
7 6
5
The optimal way to win the game is for one character to visit level
Time Limit: 1 second
You are working hard to prepare a fun party for your fun friends.
Fortunately, you have just located the perfect venue for the fun party:
a fun palace. The fun palace has
Fun tunnels can be in one of two states: open or closed. When the fun
tunnel between fun rooms
By default, the fun tunnels will all be closed. However, they may
temporarily be opened by a group of fun friends pressing down a required
number of fun buttons. For each fun tunnel, there is a set of
fun buttons present in the fun rooms connected to the fun tunnel. If all
of the buttons in one of the rooms connected to a tunnel are pressed
down by distinct fun friends, then the fun tunnel will open. Otherwise,
the fun tunnel will immediately close. The fun tunnel between rooms
The exit tunnel operates under similar rules, but it is only
connected to a single set of
You want to ensure your friends have maximum fun, and that obviously means keeping your fun friends trapped in the fun palace forever. What is the maximum number of fun friends that you can distribute to particular fun rooms such that the exit fun tunnel is never opened?
The first line will contain a single integer
For 3 of the 25 marks available,
For an additional 5 of the 25 marks available,
For an additional 12 of the 25 marks available,
Output a single integer, the maximum number of fun friends over all possible distributions of fun friends to fun rooms such that there is no way for the fun friends to open the exit tunnel.
2
20
5 5
19
If we had any more than 19 fun friends, then they would be able to move to fun room 1 and press all 20 fun buttons required in order to open the exit tunnel.
2
20
5 20
24
Suppose we place 24 fun friends in fun room 2. In order to open the fun tunnel between fun rooms 1 and 2, 20 fun friends must stay in fun room 2 to press the fun buttons. This allows only 4 fun friends into fun room 1, which is not enough to press every fun button in the set of 5.
7
7
2 8
6 6
1 1
2 4
2 8
7 8
23
One optimum distribution is to place 9 fun friends in fun room 2 and 14 fun friends in fun room 7.
Time Limit: 1 second
Troy wants to play the following game with you.
He has a grid with
There are
Your goal is to find the minimum score of any cell in the grid.
Unfortunately, Troy does not tell you how many tokens there are or where
they are placed. However, you may ask him questions. You can ask Troy to
tell you the score of any cell
This problem is interactive: input will be given based on questions generated by your program.
First, read one line with three integers
After your program has read this line, your program may ask questions.
To ask a question about
Once your program determines the minimum score is
The output must be flushed after every line is printed, including the
last line. To flush you can use: fflush(stdout)
or
cout << endl
in C/C++;
System.out.flush()
in Java; flush(output)
in
Pascal.
If any printed line is wrongly formatted or you ask more than
For every test case, the grading system will have fixed integer
values
For
For an additional
For an additional
For an additional
For the remaining
Request to grader | Feedback from Grader |
---|---|
1 10 90 |
|
? 1 3 |
9 |
? 1 7 |
11 |
? 1 4 |
8 |
! 8 |
This sample corresponds to tokens at cells
The score of cell
The score of cell
The score of cell
For information, here are the scores in this example:
Column | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
---|---|---|---|---|---|---|---|---|---|---|
Score | 13 | 10 | 9 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Request to grader | Feedback from Grader |
---|---|
5 4 170 |
|
? 2 4 |
11 |
? 1 4 |
15 |
? 3 3 |
7 |
! 7 |
This sample corresponds to tokens at cells
Time Limit: 8 seconds
You have a schedule of
There are
The first line will contain three integers
For 5 of the 25 available marks,
For an additional 10 of the 25 available marks,
Output
4 3 1
6 1 2 4
1 3
8
6
For the original schedule, it is best to attend the first three
lectures and remember the first and third, for an overall value of
Time Limit: 2 seconds
Desperate to contribute to the CCO, Robert tried inventing a segment tree problem. The specification for that problem is:
You are given a list of
distinct integers between and . These are arranged in a row such that the -th integer from the left is , where . We define a flop operation on a set of elements as swapping the minimum element of the set with the maximum element of the set. There will be flop operations, each specifying two numbers and . For each operation, you must perform a flop on the interval (that is, on the segment of numbers ). You must perform the flops in the order given, and report the final result.
Now that he is finished with the problem statement, Robert needs to create some test data. For one test case in particular, he is trying to encode an inside joke into the initial and final sequences of numbers. With these two sequences fixed, help him find any sequence of flop operations that transforms the first sequence into the second.
The first line will contain the integer
The first line of output should contain the integer
For 5 of the available 25 marks,
For an additional 10 of the available 25 marks,
6
1 3 5 6 4 2
1 2 3 4 5 6
4
2 3
3 6
2 5
4 5
The first flop swaps 3 and 5, the second flop swaps 6 and 2, the third flop swaps 5 and 2, and the fourth flop swaps 5 and 4.