Time Limit: 2 seconds
Troy is planning to take a group photo of the students at CCO and has asked you for help.
There are
Troy has prepared a sequence
Troy will ask you
Note that each of the
The first line of input will contain three space-separated integers
The second line of input will contain the array
The next
Marks Awarded | Bounds on |
Bounds on |
Bounds on |
---|---|---|---|
4 marks | |||
6 marks | |||
7 marks | |||
8 marks |
Output YES
or
NO
.
6 3 3
1 1 2 3 1 2
1 2
2 5
2 6
NO
YES
NO
For the first query, we will never have
For the second query, one solution to
For the third query, we cannot have both
Time Limit: 1.5 seconds
There are
For each
Right now, the
Suddenly, it starts raining, and everyone at market
to go to bus shelter
to go to bus shelter
to stay and buy an umbrella.
If a person is unable to find a place in a bus shelter or buy an umbrella, they will get wet.
If everyone coordinates optimally, can they all stay dry? If so, what is the least amount of money they need to spend, and which bus shelter should each person move to?
The first line of input contains
The second line of input contains
The third line of input contains
The fourth line of input contains
Marks Awarded | Number of bus shelters | Maximum people/bus shelters | Maximum people/market | Maximum umbrellas/market |
---|---|---|---|---|
5 marks | ||||
5 marks | ||||
6 marks | ||||
9 marks |
If every person can stay dry either under an umbrella or at a bus
shelter, the output will be
the first line will contain the word
YES
.
the second line will contain the least amount of money necessary to spend on umbrellas
the next
the number of people at market
the number of people at market
the number of people at market
where
If not every person can stay dry, the output will be one line
containing the word NO
.
If there are multiple possible correct outputs, any correct output will be accepted.
3
10 15 10
20 20
0 0
NO
There are 35 spots available at bus shelters and no umbrellas available, but there are 40 people in the markets.
3
10 15 10
20 20
0 11
YES
5
10 0 10
5 5 10
Looking at market 1, 10 people will go to bus shelter 1, no one will buy an umbrella, and 10 people will go to bus shelter 2.
Looking at market 2, 5 people will go to bus shelter 2, 5 people will stay and buy an umbrella, and 10 people will move to bus shelter 3.
In total, 5 umbrellas were purchased, which costs $5.
Time Limit: 3 seconds
Due to a rather ambitious school schedule, two of your classes are about to be held starting at exactly the same time, in two different classrooms! You can only be in one place at a time, so the best you can hope for is catching the important bits of both, even if that means sneaking back and forth between the two.
The two classrooms are numbered
You begin the day in classroom 1 with both classes starting at time
0. Following that, at any point in time (not necessarily after an
integral number of seconds), you may move from your current classroom to
the other one in
For example, if classroom
What’s the maximum number of distinct slides which you can see at least once?
The first line contains three space-separated integers,
The next
The next
Marks Awarded | Bounds on |
Bounds on |
Bounds on |
---|---|---|---|
5 marks | |||
10 marks | |||
6 marks | |||
4 marks |
Output one integer which is the maximum number of distinct slides which you can see.
3 1 8
10 20
100 101
20 21
15 25
3
One possible optimal strategy is to remain in classroom
1 5 3
1 100
1 2
2 3
3 4
4 5
5 6
4
Even if you begin moving to classroom
Time Limit: 1 second
In a parallel universe, everyone scored perfect on the CCO. As a
result, Troy needs to pick the winner based on a lottery. Each
contestant will choose numbers to create a ticket. A ticket is an array
of size
The winning ticket is determined by dropping
Each ball has a designated drop node that it will drop at. When a ball is dropped at an unoccupied node or enters an unoccupied node, one of three things happens:
If all of the current node’s children are occupied by balls (or if a node has no children), the current ball rests at the current node. That is, it remains there and does not move again.
If the current node only has one unoccupied child, the current ball will move to this child.
If the current node has two unoccupied children, and if the current ball was just dropped, it could go either left or right. Otherwise, it will continue in the direction of its previous movement.
If all
If all
Troy would like to know the number of possible winning tickets (which could be zero).
The first line contains two space-separated integers
The next line contains
The last
Marks Awarded | Bounds on |
Bounds on |
Additional constraints |
---|---|---|---|
3 marks | None | ||
4 marks | All nodes do not have a left child | ||
9 marks | The |
||
9 marks | None |
Output the remainder of the number of winning lottery tickets divided
by
5 2
1 3
2 3
0 0
4 5
0 0
0 0
4
The tree looks like this:
Consider when ball 1 is dropped first. If ball 1 goes left, then it will rest at node 2. Afterward, ball 2 is dropped and can rest at node 4 or 5. If ball 1 goes right, it will rest at node 5. Then, ball 2 will rest at node 4.
Consider when ball 2 is dropped first. Ball 2 can go left or right, resting at nodes 4 or 5, respectively. Then if ball 1 moves left after being dropped, it will rest at node 2. However, if ball 1 moves right, it will rest at either node 4 or 5, whichever place ball 2 does not occupy.
The possible winning tickets are
4 3
1 2 4
0 2
0 3
0 4
0 0
2
The tree looks like this:
This test case satisfies the second subtask.
Ball 3 must be dropped first because if either ball 1 or ball 2 are dropped before ball 3, it would rest at node 4, which wouldn’t allow ball 3 to be dropped.
Thus, we can either first drop ball 3, then ball 2 and finally ball 1 or we can first drop ball 3, then ball 1 and finally ball 2.
The possible winning tickets are
A binary tree is a set of nodes that is either
empty, or a root node with a left subtree and a right subtree both of
which are binary trees. Given a node
Time Limit: 3 seconds
The mayor of CCOland, Jason, wants to install telephone lines amongst
Two households can only communicate with each other if they are
connected by a path of telephone lines of the same
company. Jason would like to buy one phone plan from each
company of minimal cost such that there are at least
The first line contains four space-separated integers
The next
The next
Marks Awarded | Bounds on |
Bounds on |
Bounds on |
Additional Constraints |
---|---|---|---|---|
6 marks | None | |||
5 marks | Keenan Mobile Phones only connects to odd indexed households; Chris Home Telephone only connects to even indexed households | |||
6 marks | None | |||
8 marks | None |
Output the cheapest cost needed to connect at least
6 4 4 9
1 2 1
2 3 2
1 4 3
3 4 4
5 6 40
1 5 30
2 6 20
3 6 10
33
For each company, consider these pictures of the way the 6 households are connected by telephone lines:
Keenan Mobile Phone
Chris Home Telephone
If Jason buys phone plan level
Time Limit: 1 second
Finn is playing a game of Twos and Threes. Twos and Threes is a
one-player game played on a one-dimensional board. In the starting
position, there are
Select
Finn wins the game if all blocks are removed from the board. Your task is to help Finn determine a winning sequence of moves, or determine if the game cannot be won.
The first line of input will contain the integer
The second line of input will contain the string
Marks Awarded | Bounds on |
---|---|
3 marks | |
6 marks | |
7 marks | |
9 marks |
If there is a winning sequence of moves, output
If there is no winning sequence of moves, output
If there are multiple winning sequences, then any winning sequence
will be accepted. There is no need to minimize or maximize
9
ABAABBBAA
4
6 2
3 2
2 2
1 3
The sample output denotes this winning sequence:
ABAABBBAA
ABAABAA
ABBAA
AAA