0% found this document useful (0 votes)
23 views7 pages

2021 PO R2 Question Paper

The document describes the rules and instructions for the Programming Olympiad 2021 Round 2 contest. It provides details on the contest format, including 4 questions worth 100 marks each, a 2 hour time limit, and restrictions on submissions. Candidates will compete by writing programs to solve problems presented as text-based inputs and outputs on an online evaluator platform.

Uploaded by

lesegowubet4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views7 pages

2021 PO R2 Question Paper

The document describes the rules and instructions for the Programming Olympiad 2021 Round 2 contest. It provides details on the contest format, including 4 questions worth 100 marks each, a 2 hour time limit, and restrictions on submissions. Candidates will compete by writing programs to solve problems presented as text-based inputs and outputs on an online evaluator platform.

Uploaded by

lesegowubet4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Programming Olympiad 2021: Round 2

Not to be used before 6 September 2021

1. Make sure you understand everything in the “Rules & Instructions” tab of the contest before you
start your timeframe.
2. The contest will open at 6 AM Monday 6 September and will shutdown at 6 PM.
3. This paper is only for invited Round 2 candidates. They will see the questions and submit
programs on the saco-evaluator.
4. Any attempt to access any other website or source of information will disqualify you. Programs
must pass the plagiarism check to be deemed valid.
5. Log on using the username and password given to you by your teacher.
6. There are four questions. There are 100 marks for each question. Each question is made up of
subtasks. There are different marks for each subtask.
7. For each subtask, your score will be the highest score obtained across all your submissions for
that question.
8. You will only be permitted to submit at most 30 submissions for the 2 hours of the contest.
9. You will have two hours (120 minutes) to complete all 4 questions.
10. You may assume that the user input will satisfy the problem specification and so you do not
need to validate the input.
11. You may use the Communication pane (top left) but note that responses may be delayed.
12. You should not write code to produce only specific answers, as the judges will use other test
cases.
13. Do not wait until the last few minutes to submit your programs.
14. After 120 minutes, or at 6:00 PM, whatever comes first, the server will end your participation.
Should you finish before the time, check that you have answered all the questions.
15. Scores per question will be sent to your school after 6 September.
Question 1 – Latest letter

Input file: standard input


Output file: standard output
Time limit: 0.5 seconds
Memory limit: 64 megabytes

Write a program to determine the latest letter in the alphabet used in a word or sentence. “G” appears
later than “E”. The letters must all be converted to uppercase.

Input
The input consists of one line containing a single string. The characters of the string consist of both
lowercase and uppercase Latin letters from A-Z.

Output
A single uppercase character, the latest letter.

Scoring
Subtask 1: (0 points) Examples.
Subtask 2: (100 points) No further restrictions.

Examples

standard input standard output


HEy Y

SupeR U

YoRHa Y
Question 2 – Candy Coupon

Input file: standard input


Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
Points available: 100

A candy store is having a special, where they sell any piece of candy for R1. Additionally, each piece of
candy contains a coupon inside the wrapper, and coupons can be exchanged for another piece of candy!
Given the amount of money you start with and the number of coupons required to exchange for a piece of
candy, determine the maximum amount of candy you can obtain (through buying candy and exchanging
coupons for candy).

Input
The only line of input consists of two integers n and k (1 ≤ n ≤ 109; 2 ≤ k ≤ 109). n is the amount
of money you start with (in rands), and k is the number of coupons required to exchange for a piece of
candy.

Output
Output a single integer, the total amount of candy you can obtain.

Scoring
Subtask 1: (10 points) Examples.
Subtask 2: (10 points) k > n.
Subtask 3: (20 points) k = 2.

Subtask 4: (20 points) k ≥ √𝑛.


Subtask 5: (40 points) No additional constraints.

Examples
standard input standard output
22 3
10 3 14
37 4 49

Note
In the first example, you start with R2. You can buy 2 pieces of candy, and exchange two coupons for
one more candy, for a maximum total of 3 candy.

In the second example, you start with R10. You can buy 10 pieces of candy, and exchange 9 coupons for
3 additional candy. Now you have 4 coupons left, and can exchange 3 of these for one more candy, giving
you the maximum total of 14 candy.
Question 3 – GoFarAlice

Input file: standard input


Output file: standard output
Time limit: 1 second
Memory limit: 1024 megabytes
Points available: 100

Alice wants to go far away. As far away as possible even. But first Alice must plan how far away she can
actually go.

Alice plans to drive on a road, with her car, in the + 𝑥 direction. Alice’s car uses 1 litre of fuel per unit
distance travelled. Luckily, she can refuel at cities along the way. But fuel costs money, and Alice only has
M rand. On this road there are N cities. City i is at co-ordinate 𝑥𝑖 , and the price per litre of fuel is 𝑣𝑖 .
By working out how much and where to buy fuel, work out the maximum possible distance Alice can
travel.

Input
The first line contains 2 space separated integers M (1 ≤ M ≤109) and N (1 ≤ N ≤ 2 ∙ 105). Line i of
the following N lines contain 2 space separated integers 𝑥𝑖 (0 ≤ 𝑥𝑖 ≤ 109) and 𝑣𝑖 (1 ≤ 𝑣𝑖 ≤ 104). It is
guaranteed that 𝑥0 = 0 and that 𝑥𝑖 < 𝑥𝑖+1.

Output
Output a single integer, the maximum distance Alice can travel.

Scoring
Subtask 1: (0 points) Examples.
Subtask 2: (5 points) N = 1.
Subtask 3: (15 points) N = 2.
Subtask 4: (10 points) For i = 1; 2,…, n − 1 it is given that 𝑣𝑖 > 𝑣𝑖+1.
Subtask 5: (20 points) N ≤ 104.
Subtask 6: (50 points) No further restrictions.

(Turn the page to see examples)


Examples
standard input standard output
19 4 5
05
32
53
81
53 0
09
11
10 1
25 6 11
04
13
32
53
82
10 1

Note
Alice’s car can carry arbitrary large amounts of fuel. Alice’s car starts with 0 fuel, but there is always
a city at location 0 (the starting 𝑥 coordinate of Alice). Alice can only buy integer units of fuel (Alice
cannot buy half a litre of fuel).
Question 4 – BigFungus

Input file: standard input


Output file: standard output
Time limit: 1 second
Memory limit: 1024 megabytes
Points available: 100

You are growing a special fungus in a patch. The patch is an n × m rectangle. The top-left cell of the
patch begins with 1 unit of fungus. Every minute, the fungus in each cell increases by the sum of the units
of fungus in its neighbours (two cells are neighbours if they share an edge). Determine the total amount
of fungus after k minutes.

Input
The only line of input consists of three integers k, m and n (1 ≤ k; m; n ≤ 100).

Output
You must determine the total units of fungus after k minutes. As this number can be very large, you must
output the remainder of this after division by 1 000 000 007.

Scoring
Subtask 1: (10 points) Examples.
Subtask 2: (10 points) k = 1.
Subtask 3: (10 points) n = 2; m = 1; k ≤ 10.
Subtask 4: (10 points) k ≤ 10.
Subtask 5: (10 points) n = 2; m = 1.
Subtask 6: (10 points) m = 1.
Subtask 7: (10 points) It’s guaranteed that the total units of fungus will be less than 109.
Subtask 8: (30 points) No additional constraints.

(Turn the page to see examples)


Examples
standard input standard output
322 27
232 10
456 177

Note
In the first example, the fungus grows as follows:

You might also like