Welcome to the first round of the Swiss Olympiad in Informatics! You will find below an overview of what you’ve done so far as well as a few things that you should know before getting started.
This contest is over.
Category | Task | Total | Subtask 1 | Subtask 2 | Subtask 3 | Subtask 4 | Subtask 5 |
---|---|---|---|---|---|---|---|
Junior only | peaks | ‒/100 | ‒/10 | ‒/10 | ‒/30 | ‒/20 | ‒/30 |
Junior only | ropeways | ‒/100 | ‒/10 | ‒/20 | ‒/30 | ‒/40 | |
Both | tshirts | ‒/100 | ‒/5 | ‒/10 | ‒/20 | ‒/25 | ‒/40 |
Both | clawsort | ‒/100 | ‒/15 | ‒/10 | ‒/20 | ‒/55 | |
Both | dancing | ‒/100 | ‒/5 | ‒/10 | ‒/12 | ‒/16 | ‒/57 |
Regular only | rerouting | ‒/100 | ‒/10 | ‒/20 | ‒/30 | ‒/40 | |
Regular only | tinmining | ‒/100 | ‒/15 | ‒/15 | ‒/15 | ‒/15 | ‒/40 |
Mouse Stofl will lead the Swiss delegation at the Mouse Olympiad in Informatics in Indonesia this year. According to tradition, he wants to hand out gifts related to Switzerland to participants from other countries. He has found a cheap type of presents: postcards! He wants to buy some with beautiful pictures of the Swiss mountains. The most beautiful pictures are those in which one can see many peaks. There are many available pictures and Stofl wants you to help him count how many peaks there are on some of them.
A picture can be described as a sequence of integers . Each number represents the height of the mountains at the horizontal coordinate on the postcard. There is a peak at coordinate if and only if that coordinate has two neighbours that are lower than it. That means there is a peak at when and . Note, in particular, that there is never a peak at coordinates and , because those have only one neighbour.
Mouse Stofl starts by asking you to test your program on a very small picture with just mountains to see how the postcards look like without paying for huge ones. There are only three coordinates on the picture, and you should tell whether there is a peak on it.
The first line contains the number of test cases . test cases follow of the following format:
For the -th test case, print a line “Case #i:” followed by “yes” if there is a peak on the picture or “no” if there is not.
Input:
4 3 2 4 1 3 8 6 3 3 8 6 8 3 4 5 5
Output:
Case #0: yes Case #1: no Case #2: no Case #3: no
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Mouse Stofl continues with a larger picture containing mountains. This time, you should not tell him if there is a peak, but tell him how many there are instead.
See Subtask 1.
For the -th test case, print a line “Case #i:” followed by a single integer, the number of peaks in that picture.
Input:
2 5 2 4 3 4 1 5 3 7 8 8 10
Output:
Case #0: 2 Case #1: 0
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Now, the picture is really large. You should once again tell Stofl how many peaks it displays.
See Subtask 1.
See Subtask 2.
Input:
1 7 2 4 3 3 5 1 2
Output:
Case #0: 2
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Those large postcards that Stofl showed you are made for humans, not for mice! He didn’t realise it at first, but he can’t pack them in his bags. Therefore, he wants to cut the picture so that it only contains coordinates. Tell him how many peaks he can keep on the picture if he cuts it optimally. Formally, you have to find the contiguous subsequence of length in the given integers that contains the largest amount of peaks.
The first line contains the number of test cases . test cases follow of the following format:
Print the maximum amount of peaks that one can fit on a contiguous part of the original picture of size .
Input:
1 12 6 3 6 4 2 1 2 1 5 3 2 6 3
Output:
Case #0: 2
Comment:
You can move the cutout with your mouse.
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Stofl wants to use and cut even bigger postcards, so you need to be very smart to compute efficiently how many peaks he can get this time!
See Subtask 4.
See Subtask 4.
See Subtask 4.
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Ropeways are used to transport people and goods across difficult terrain. A famous example of a ropeway is the gondola at Timang Beach. Originally built to ferry fisherman from the coast to a lobster nest on Pulau Timang, nowadays it is a popular tourist attraction.
As soon as she saw that there are more islands aligned on a line to the right of Pulau Timang, Mouse Binna had an idea for a new business opportunity: let’s build a system of ropeways that connects Pulau Timang with the right-most island.
Let’s number the islands from to . Mouse Binna wants to connect island (Pulau Timang) with island using a set of ropeways.
Ropeways have a maximum length and can connect two islands that are up to apart. Formally, a ropeway can connect island with island if and are satisfied.
You are given the heights of islands on the shore. A ropeway from to is fun if (it goes down very fast) and is boring if (it needs to be motor-powered which is slow).
Help Binna to decide which ropeways to build such that it is possible to go from to using the least amount of boring ropeways, for different values of .
All subtasks have the same input and output format.
The first line contains the number of test cases . test cases follow of the following format:
For the -th test case print a line “Case #i:” followed by numbers, where the -th number is the minimum number of boring ropeways for a system where each ropeway has length at most .
Mouse Binna has found a quality manufacturer that produces ropeways that have a maximum length of (thus it is one short to cover the whole range). Note that in this subtask and .
Input:
3 3 1 3 1 4 1 4 1 1 3 3 7 2 5 1 999999999 1000000000 1 500000000 1 3
Output:
Case #0: 1 Case #1: 2 Case #2: 0
Comment:
It is optimal to have exactly 0 boring rides.
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
This time Mouse Binna wants to go for cheaper ropeways that have a maximum length of either or . Note that in this subtask and and .
Input:
2 3 2 11 22 33 1 2 15 2 3 1 2 1 4 5 4 4 3 3 9 4 7 5 5 1 2
Output:
Case #0: 2 1 Case #1: 8 2
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Mouse Binna has found a manufacturer that can produce ropeways of any quality. So she wants to know the answers for arbitrary values of , but first on a segment with fewer islands. Note that in this subtask .
Input:
1 100 7 7 2 8 4 7 5 4 5 10 4 3 4 6 2 9 2 5 8 3 7 9 4 4 2 1 2 7 8 1 8 8 9 8 8 6 9 1 5 5 2 6 6 2 1 8 8 9 9 5 5 7 7 9 9 8 10 9 5 2 6 10 1 4 4 4 1 3 8 3 3 10 10 5 8 8 6 3 1 1 9 10 6 4 5 4 6 4 3 9 3 4 7 4 5 8 4 9 4 9 6 5 2 3 9 6 10 9
Output:
Case #0: 7 25 12 2 6 2 2
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
The last step is to build a large network of ropeways for arbitrary values of . Everything is the same as in the previous subtask, except that and can be much larger.
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
The Mouse Olympiad in Informatics takes place in Indonesia this year and Mouse Binna is in charge of ordering the T-shirts. This turns out to be more difficult than anticipated because Java, where Yogyakarta is located, has four spoken languages. Javanese, the commonly spoken language in Yogyakarta, even uses their own numerals. This is very confusing and every time Binna orders T-shirts they arrive in all the wrong sizes! Help Binna to make the best out of the situation.
To check out the design, Binna ordered one T-shirt for herself. The T-shirt that arrived had size . Binna can wear any T-shirt of size at least and at most . Can she wear the T-shirt that arrived?
The first line contains the number of test cases . test cases follow of the following format:
For the -th testcase, output a line containing “Case #i:” followed by “Yes” if the T-shirt fits, and “No” it does not.
Input:
3 1 5 7 10 20 13 3 100 2
Output:
Case #0: No Case #1: Yes Case #2: No
Comment:
The first line with “3” indicates that there are three test cases.
Case #0: The next two lines are “1” and “5” and describe that Binna can wear a T-shirt of size at least and at most . The next line is “7”, which means that the ordered T-shirt has size . This T-shirt is too large for Binna, therefore the output for “Case #0” is “No”.
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Now Mouse Binna wants to order the T-shirts for the participants and she found a factory that produces T-shirts in only one size. But since she can’t predict what size arrives anyway, she thought that should be alright.
She noted down the sizes of the participants: participant can wear a T-shirt of size at least and at most .
Finally Binna received the order and figured out she got T-shirts of size . How many mice can wear a T-shirt?
The first line contains the number of test cases . test cases follow of the following format:
For the -th testcase, output a line containing “Case #i:” followed by a single integer, the number of T-shirts that can be assigned to mice satisfying the constraints described above.
Input:
2 5 1 7 3 5 10 4 9 8 10 15 6 3 4 100 80 70 120 1000 73
Output:
Case #0: 2 Case #1: 0
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
The Rat Olympiad in Informatics is also taking place in Indonesia this year. The organizers liked Binna’s T-shirt design so much that they stole all large T-shirts for their participants. The T-shirts that are left were too small for the rats and definitely can’t be too big for the mice. Therefore, in this subtask, Mouse Binna only needs to make sure the mice get a T-shirt that is bigger than their minimum size.
How many mice can get a T-shirt with a size that fits them, assuming we distribute the T-shirts optimally among them? Note that each T-shirt can only be assigned to at most one mouse.
The first line contains the number of test cases . test cases follow of the following format:
For the -th testcase, output a line containing “Case #i:” followed by a single integer, the number of T-shirts that can be assigned to mice satisfying the constraints described above.
Input:
2 3 4 1 7 3 4 9 8 3 2 4 2 5 4 12 17 3 1 9 20 30 15 22 31 4 14 13 7
Output:
Case #0: 2 Case #1: 4
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Finally, the T-shirts have arrived. This time Binna also needs to consider the maximum size of the participants. Help Binna to find out how many mice can wear a T-shirt.
See Subtask 3.
Input:
2 3 4 1 7 3 4 9 8 5 2 9 2 5 4 12 17 3 1 9 20 30 15 22 31 4 14 33 17
Output:
Case #0: 3 Case #1: 3
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
The Mouse Olympiad in Informatics is a large event with many mice, so there can be up to participants.
See Subtask 3.
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Mouse Stofl has built a robot with a claw attached, which can pick up and put down objects. The robot also has wheels, and can move to the left or to the right.
The robot can be in one of positions, and it starts at position . When it starts, its claw is empty. The robot can be controlled by giving it one of two possible commands:
The robot cannot move outside of the positions.
In order to test the robot, Stofl has placed a row of cards with numbers on them on the floor, but they are all jumbled up. He wants to use the robot to sort the numbers in increasing order. Can you help him?
Mouse Stofl has written a list of commands which he thinks will sort the cards, but he is not sure if it is correct. Simulate the robot and tell Stofl in what order the cards are afterwards.
The first line contains the number of test cases . test cases follow in the following format:
It is guaranteed that after executing all commands of a test case, the robot will end up with an empty claw.
You should output lines, one for each test case. For the -th test case, output “Case #i:” followed by numbers, the numbers on the cards from left to right after the robot has executed the commands.
Input:
2 2 1 0 ><>. 3 2 0 1 >><><<>.
Output:
Case #0: 0 1 Case #1: 1 0 2
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Evidently, Mouse Stofl is not very good at giving the robot commands for correctly sorting cards. Can you do it better?
To start with, he only asks you to sort three numbers.
The first line contains the number of test cases . test cases follow in the following format:
You should output lines, one for each test case. For the -th test case, output “Case #i:” followed by a list of commands, which consists of characters “>” or “<”, followed by “.”.
Input:
2 3 2 0 1 3 0 1 2
Output:
Case #0: ><>><<. Case #1: .
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Mouse Stofl noticed that his cards are already sorted in decreasing order. That’s bad, because he wants to have them in increasing order. Can you help him reverse them?
Same as subtask 2.
Note that every input file looks exactly the same.
Input:
2 1 0 2 1 0
Output:
Case #0: . Case #1: ><><><><>.
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Can you solve the final challenge and sort up to 300 cards with the robot? Sorting so many cards takes a lot of time and Stofl is in a hurry. Therefore he will pay you points depending on how fast your robot is. See scoring section for more details.
Same as subtasks 2 and 3.
You can get a variable amount of points for this subtask.
7 points if you only solve the first 30 test cases (0 to 29), where we have .
20 points if you only solve the first 60 test cases (0 to 59), where we have .
25–55 points if you solve all test cases. In all test cases, . The score of a test case is calculated as follows.
Your total score is the minimum score over all test cases.
Click below for some reference values for this function:
Input:
3 4 2 1 3 0 5 3 2 0 4 1 6 0 5 3 1 2 4
Output:
Case #0: >>><<><<><>>. Case #1: >><>>><<><<<>><<. Case #2: >><<>>><>><>><<<<<.
Note: The upload limit is 10 MiB. If you exceed that you get an error “413 Request Entity Too Large”. Most likely this is because you exceed the move limit. In that case, just upload the first 60 test cases (you won’t get more than 20 points anyways if you exceed the limit).
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Mouse Stofl is organizing a stage dance for mice. The mice will stand in a circle, and then during the dance the mice that stand next to each other in the circle can form pairs. During each moment, one mouse can belong to at most one pair, but the pairs can change during the dance. For example, for the mice can first form pairs as 0+1, 2 (dancing alone), 3+4, and then change to 1, 2, 3, 4+0 (remember that since they are standing in a circle mouse can form a pair with mouse 0), and so on.
For each pair of adjacent mice and (or and for ), Stofl has prepared a sequence of dance moves that they will perform as a pair, which lasts for seconds. These moves do not have to be performed as one consecutive segment – for example, if , the pair can dance together for 1.5 seconds, then the two mice can form different pairs or dance alone for some time, and then they can form a pair again and dance for the remaining 3.5 seconds. It’s OK to split this dancing time into more than two segments, too.
Now Stofl is wondering how to put all those moves together into one big dance for all mice. More specifically, you need to help Stofl design a dance with the shortest overall duration that allows mice and (or and for ) to dance as a pair for at least seconds for each .
All subtasks have the same input and output format.
The first line contains the number of test cases . test cases follow of the following format:
For the -th test case, output a line containing “Case #t:”, followed by a space and an integer : the number of sections in the dance you designed. A section is a part of the dance during which the pairs do not change. In the following lines, describe the sections. Each section is described by its duration in seconds (a floating-point number), followed by a space and a string of characters without spaces. If the -th mouse is dancing alone, the -th character of that string should be a dot (.). If the -th mouse is dancing together with the -th mouse (or, in case , with the 0-th mouse), the -th character of that string should be a less-than sign (<). If the -th mouse is dancing together with the -th mouse (or, in case , with the -th mouse), the -th character of that string should be a greater-than sign (>).
Your answer will be accepted if the following conditions hold:
It is guaranteed that there always exists a dance with the shortest possible duration that has at most sections.
In this subtask there are only three mice dancing.
Input:
1 3 1 2 3
Output:
Case #0: 3 1.0 <>. 3 >.< 2 .<>
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
In this subtask all pairs of adjacent mice have to dance together for exactly 1 second.
Input:
2 4 1 1 1 1 5 1 1 1 1 1
Output:
Case #0: 2 1 <><> 1 ><>< Case #1: 5 0.5 <><>. 0.5 <>.<> 0.5 .<><> 0.5 ><>.< 0.5 >.<><
Comment:
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
In this subtask the last and the first mice do not have to dance together.
Input:
1 5 1 2 3 2 0
Output:
Case #0: 2 3 <><>. 2 .<><>
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
In this subtask the number of mice is even.
Input:
1 6 1 2 3 2 5 1
Output:
Case #0: 2 5 <><><> 2 ><><><
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
In this subtask the number of mice is odd.
Input:
1 7 1 2 5 2 5 2 5
Output:
Case #0: 7 4.333333333333 >.<><>< 1.333333333333 .<><><> 0.333333333333 <><><>. 0.333333333333 <>.<><> 0.333333333333 <><>.<> 0.333333333333 ><><>.< 0.333333333333 ><>.<><
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Indonesia is the largest archipelagic country in the world, stretching over 5000 kilometres from east to west. It consists of over 17000 islands of which about 6000 are inhabited, with rainforest covering most of these islands.
Mouse Stofl is working in the Indonesian mouse ferry organization, more specifically, he is responsible for planning the routes of the ferries. The islands currently served by the mouse ferry organization are connected by ferries, where each ferry connects two islands, in such a way that it’s possible to get from any island to any other island by using ferry-connections.
Recent analysis has showed that the network is not as efficient as it could be. Mouse Stofl has compiled a list of new connections, so that it’s still possible to get from any island to any other island only using connections from his list. He now wants to replace the old connections with his new connections.
However, if Mouse Stofl replaced all the connections at once, the other mice would be confused and wouldn’t know which ferries to take. Mouse Stofl decided that he will change exactly one connection per day. This means, every day, he replaces one of the current ferry-connections with an arbitrary new connection, which is not necessarily on his list. However, as the mice continue travelling during this process, at any day, it must be possible to get from any island to any other island.
Mouse Stofl wants the rerouting process to finish and the new connections to be in place as soon as possible. Thus he asks you to find the minimal number of days and which connections he should replace on each day.
Mouse Stofl initially isn’t sure about his plan. He fears that it might take too long until the new connections are in place. That’s why he only wants to know the minimal number of days and why he doesn’t need to know which connections to replace.
The first line contains the number of test cases . test cases follow.
For the -th test case print a line “Case #i:” followed by a single integer: the minimal number of days needed until all the new connections are in place.
Input:
3 4 0 0 0 1 2 3 0 1 2 1 2 3 6 0 2 4 2 5 2 1 5 3 2 3 4 3 1 4 5 2 0 3 3 5 0 2 2 1 1 1 4 3 3 0 3 4 1 2 2 2
Output:
Case #0: 2 Case #1: 5 Case #2: 2
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Mouse Stofl has now decided that he wants to implement his plan. However, he is currently only responsible for a small region only consisting of approximately 100 islands.
See subtask 1.
For the -th test case print a line “Case #i:” followed by a single integer : the minimal number of days needed until all the new connections are in place. Then output lines. The -th line consists of four integers and , meaning that on day , the connection between and should be replaced by the connection between and .
Input:
3 4 0 0 0 1 2 3 0 1 2 1 2 3 6 0 2 4 2 5 2 1 5 3 2 3 4 3 1 4 5 2 0 3 3 5 0 2 2 1 1 1 4 3 3 0 3 4 1 2 2 2
Output:
Case #0: 2 0 2 1 2 0 3 2 3 Case #1: 5 2 1 1 3 2 3 3 5 4 5 4 2 5 2 3 0 0 2 4 3 Case #2: 2 2 1 0 2 0 1 2 3
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Mouse Stofl got promoted and is now responsible for all of Indonesia. However, only the inhabited islands are currently served by ferries.
See subtask 2.
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Mouse Stofl was so successful in his business, that he is now responsible for organizing the ferry routes of the worldwide mouse ferry organization. They connect islands worldwide, however, not all the islands can be served as there are simply too many. The organization currently serves approximately islands.
See subtask 2.
Since we can’t ensure that optimized brute-force solutions or heuristics won’t be able to pass, we will manually check all submissions and may retroactively give an accepted submission 0 points.
We expect a solution that runs in (for a constant ) or , where is the inverse Ackermann function. See Introduction to Algorithm Design for explanation of the -notation.
Furthermore, as we can’t distinguish the different running times, we will manually check your submissions and score them according to this table:
Running time | Score |
---|---|
40 | |
32 | |
for | 25 |
Note: We need around 15 seconds to verify your submission. Please be patient.
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Due to its geographic location in the Southeast Asian tin belt, Indonesia is one of the biggest exporters of tin. Unfortunately, the tin reserves of Indonesia are about to be depleted. Most mining companies have therefore decided to move their mining operations to the sea around Indonesia.
Inspired by the uprising tin-rush, mouse Binna wants to start her own mining business. A tin-mine on the sea is considerably more complicated than one on land. On the sea, a tin-mine consists of different worker nodes that are interconnected with each other to share resources and mined ore via ships. Each worker node has exactly one port for incoming ships and one for outgoing ships. In order for a node to function properly, it has to be connected to the whole network.
Binna has investigated tin deposits arranged in a circular pattern. Each worker node placed on a deposit will have a different stability level. More stable nodes are more robust and so have a bigger storage capacity for mined ore. Therefore ships can only transport mined ore in one direction, from the less stable node to the more stable one. The more nodes are connected to the whole network, the more efficient the mine can operate because more deposits can be exploited.
In a traditional tin-mine, the mined ore is transported in large trucks. Trucks are very agile and can easily maneuver around each other. On the sea however, the ore has to be transported with ships. Because ships loaded to the brim with ore are heavy and have a lot of inertia, it is important that different ship routes do not cross each other.
All subtasks have the same input and output format.
The first line contains the number of test cases . test cases follow in the following format:
For the -th test case, output a line “Case #i: M”, where is the total number of worker nodes which are needed for the optimal solution (including the one mouse Binna already constructed).
In a rush of enthusiasm, mouse Binna has already constructed the worker node that requires the highest level of stability. She now wants to know the best strategy for exploiting the highest number of tin deposits. Given a list of numbers, the different levels of stability in a circular manner, compute the size of the optimal choice of worker nodes.
There are test cases. In every test case, .
It is guaranteed that no two tin deposits require a node of the same level of stability. Therefore, the levels of stability are unique numbers in the range .
Input:
3 5 3 4 0 2 1 6 5 1 3 4 2 0 5 0 1 2 3 4
Output:
Case #0: 4 Case #1: 4 Case #2: 5
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
After starting a small mining business, Binna has collected enough capital to start bigger mining operations.
There are test cases. In every test case, .
It is guaranteed that no two tin deposits require a node of the same level of stability. Therefore, the levels of stability are unique numbers in the range .
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
After scaling up her mining operations, mouse Binna realises that her tin mine is not performing optimally. She realises that it is not always optimal to build the worker node that requires the highest level of stability. So she asks you to find the optimal without the restriction that this node is built.
There are test cases. In every test case, .
It is guaranteed that no two tin deposits require a node of the same level of stability. Therefore, the levels of stability are unique numbers in the range .
Input:
2 5 3 4 0 2 1 6 5 1 3 4 2 0
Output:
Case #0: 4 Case #1: 5
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
After testing the new algorithm, mouse Binna is very happy with the result and wants to scale up this new strategy.
There are test cases. In every test case, .
It is guaranteed that no two tin deposits require a node of the same level of stability. Therefore, the levels of stability are unique numbers in the range .
The contest is over, you can no longer submit. But you can still solve the task (‘upsolve’ it), and check your solution here.
If the time expires, or you don’t get full points, you can try again by downloading a fresh input.
You can directly run C++ solutions in your browser. For other languages, you need to download the input and manually run your solution. Please note that running in the browser is slower than running natively.
Do not navigate away while your solution is running.
Hand in a document that solves the two problems described below.
Mouse Binna has now built many different mining operations. She now has the opportunity to buy a very large mining territory in which she could scan locations. She wants to find a lower bound on the amount of the number deposits she will be able to mine in the worst case.
It is guaranteed that no two tin deposits require a node of the same level of stability. Therefore, the levels of stability are unique numbers in the range .
More specifically, if is the maximal amount of deposits that can be mined, show that
For some constant of your liking.
Describe an algorithm that solves the task in subtask 3 and 4 and analyze it. This is a theoretical task, so you should reason why your solution is correct and what asymptotic running time and memory usage your solution has.
Let be is the maximal amount of mining nodes that can be used in the optimal solution. Find an algorithm that is fast when is small!
See the table below in ‘Grading’ to see how many points can be achieved for a given runtime and memory usage.
Check out the wiki for more information on how to solve/write theoretical tasks: Theoretical Intro
Hand in a document (preferably PDF) that describes
If your algorithm is correct, we will give you points according to the table below.
Running time | Memory usage | Max score |
---|---|---|
5 | ||
15 | ||
30 |
Note that here is the maximal amount of mining nodes that can be used in the optimal solution. Additional log factors only cause minor point deductions.
The contest is over, you can no longer submit.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Rank | Username | Total (500) | peaks (100) | ropeways (100) | tshirts (100) | clawsort (100) | dancing (100) |
---|---|---|---|---|---|---|---|
loading ... |
Rank | Username | Total (500) | tshirts (100) | clawsort (100) | dancing (100) | rerouting (100) | tinmining (100) |
---|---|---|---|---|---|---|---|
loading ... |
The first line with “4” indicates that there are four test cases. The next two lines are “3” and “2 4 1” and describe the first (”Case #0”) of the four test cases. In this case, the three mountains have heights 2, 4, and 1. Below an explanation of the answers, see also the graphic after that: