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 | paragliding | ‒/100 | ‒/15 | ‒/15 | ‒/15 | ‒/25 | ‒/30 |
Junior only | rubiksknob | ‒/100 | ‒/17 | ‒/16 | ‒/23 | ‒/44 | |
Both | boulders | ‒/100 | ‒/10 | ‒/25 | ‒/30 | ‒/35 | |
Both | cardgame | ‒/100 | ‒/20 | ‒/20 | ‒/20 | ‒/20 | ‒/20 |
Both | palatinalcrypt | ‒/100 | ‒/15 | ‒/10 | ‒/25 | ‒/50 | |
Regular only | thermalsprings | ‒/100 | ‒/20 | ‒/20 | ‒/20 | ‒/40 | |
Regular only | dada | ‒/100 | ‒/10 | ‒/15 | ‒/20 | ‒/15 | ‒/40 |
Regular only | trees | ‒/100 | ‒/10 | ‒/15 | ‒/75 |
Mouse Binna has recently become interested in paragliding. She is already planning her next trip and is examining different locations where she could go paragliding. Currently, she is looking at a place range. On a map, she marked various points of interests: places where she could start or land, like peaks, cliffs, valleys etc.
The region Binna is currently looking at can be described as a sequence of places on a line, numbered from to from left to right. The -th place is located at position and its height is meters. Binna can fly from place to place if place is higher than place and also all places in between. Note that place can lie before or after place .
For each place , Mouse Binna would like to know the maximal distance she could fly starting from . The distance between two places and is defined as the absolute difference between their positions: . If, for some place, Binna can not fly to any other place, the maximal distance for this place is .
Can you help Binna to calculate for each place the maximal distance she could fly starting from there?
As Mouse Binna is not yet very experienced, she would like to start at the Uetliberg, which is a small hill next to Zurich. There is only one starting place and as unexperienced as Binna is, she would like to land on the beginner’s landing place directly below. Thus there are only two places to consider, so .
The first line contains the number of test cases . test cases follow in the following format:
For the -th testcase, output a line containing “Case #i:” followed by integers, where the -th integer is the maximum flight distance if Binna begins at place .
Input:
2 2 3 5 10 20 2 0 639 732 554
Output:
Case #0: 0 2 Case #1: 639 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.
Mouse Binna is now already feeling better. As she was enjoying her view of the Matterhorn from the Gornergrat, a rocky ridge next to Zermatt, she had the idea to paraglide at the Gornergrat. On her way back down, she wrote down a list of possible paragliding places. She was walking only downwards, meaning that in this subtask, each place is lower than the place just before it. Can you compute for her for each place how far she could fly starting from this place?
Same as subtask 1.
Input:
2 5 1 3 6 8 9 8 6 5 2 1 6 0 1430 2870 5310 7590 9340 3089 2819 2582 2210 1770 1604
Output:
Case #0: 8 6 3 1 0 Case #1: 9340 7910 6470 4030 1750 0
Comment:
Case #0: From the first place, we can paraglide down everything until place 4 for a distance of 8 meters.
Case #1: It seems like Binna didn’t walk down the Gornergrat, but took the train instead and just wrote down the different train stations. What a lazy 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.
The International Mouse Olympiad in Informatics 2023 will take place in Hungary, and Mouse Binna managed to qualify. She started looking at the different mountains of Hungary and figured out that for paragliding her best bet would be Mount Kékes. So she started looking at possible places for take-off and landing at Mount Kékes. Mount Kékes has what she calls the “standard mountain shape”. Thus for all cases in this subtask, the heights are first increasing and then decreasing. Formally, in every test case there is an index such that (note that can be or ).
Same as subtasks 1 and 2.
Input:
2 6 1 2 6 7 8 9 1 4 5 7 6 2 8 0 957 1370 1981 2873 3001 3651 4781 675 836 949 1014 885 881 730 565
Output:
Case #0: 0 1 5 6 1 0 Case #1: 0 957 1370 2800 1908 1780 1130 0
Comment:
Case #0: From place number 3, all the places are reachable, however, the longest flight can be achieved by flying all to the left until place 0.
Case #1: Did you know that Mount Kékes is only 1014 metres high?
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 figured out that if she wants to find longer paraglides, she must take into account multiple mountains instead of only a single one. Thus she is now looking at the Mátra mountain range in Hungary. She already wrote down a lot of places to look at. However, this time, there is no real pattern. Can you still help Binna and compute for her how far she can fly from each possible starting point?
Same as subtasks 1, 2 and 3.
Input:
2 5 1 2 3 4 5 5 3 1 2 4 5 1 3 6 8 9 2 1 3 5 4
Output:
Case #0: 4 2 0 1 3 Case #1: 2 0 5 7 0
Comment:
Case #0: The first place has height 5 so we can glide all the way to the last place with height 4, for a distance of 4. From the last place with height 4 we can glide to the second place, for a distance of 3. The other trips may also be shown to be maximal.
Case #1: Note that from the place with index 3 (position 8 and height 5) we may fly to the place with index 0 (position 1 and height 2) for a distance of 7, although a place between them exists with height 3. This is because only the starting height must be greater than all heights between the starting and ending place. The ending height may be lower than a place between the starting and ending place.
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.
Back in Mouseland Binna has a lot of fans. They would love to accompany her on her trip to Hungary. To make it especially interesting, Binna thought that every one of her fans should start from a different location. She still wants to make sure they’re all having as much fun as possible, so each one of their fans should fly the longest possible route.
Can you help her to plan this trip? To keep it simple, she invites only as many fans as there are places to take off from in Hungary. Now she would like to know the total distance they can manage to paraglide through Hungary together. Calculate for each place the longest possible paraglide and tell Binna the combined distance they might achieve.
Same as subtasks 1, 2, 3 and 4.
Output a single number per test case, the combined distance paraglided by all of Binna’s fans.
Input:
3 5 1 2 3 4 5 5 3 1 2 4 5 1 3 6 8 9 2 1 3 5 4 2 0 384403739351 384403739351 0
Output:
Case #0: 10 Case #1: 14 Case #2: 384403739351
Comment:
Case #0: The sample is the same as the first sample from subtask four. The combined distance is calculated as: .
Case #1: The sample is the same as the first sample from subtask four. The combined distance is calculated as: .
Case #2: Binna’s first fan flies to the second place for a distance of 384403739351mm. Note that in this scenario, Binna’s first fan starts from the surface of the moon while the second fan is waiting in Hungary. Unfortunately, the second fan can’t get to the moon from Hungary, so the total distance remains 384403739351mm.
Note that all but at most test cases in this subtask also satisfy the limits of the previous subtask. Please be patient, generating the test data can take a while.
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).
Ernő Rubik is a Hungarian inventor best known for his mechanical puzzles such as the Rubik’s Cube, Rubik’s Magic and Rubik’s Snake. Many of those puzzles have attracted a speed solving community that tries to solve the puzzles as fast as possible.
Mouse Stofl is interested in mastering a lesser known puzzle: the Rubik’s Knob.
The Knob is a round handle that can be rotated. It has an indicator that initially is pointing up. Inside the knob there is a spiral torsion spring that has a charge and tries to push the knob back to its initial position.
The knob can point to one of positions in total, numbered from to . Initially, the indicator points to position .
The spring starts with a charge of . The knob can be rotated freely in both directions:
We say a rotation is a wind-up step if it goes against the direction of the spring. Formally, this is the case if the absolute value of the charge increases (e.g. from to , or from to ).
A puzzle for the Rubik’s Knob consists of a sequence . The goal is to rotate the knob first to position , then to position , etc., until position .
By solving some puzzles by hand, Mouse Stofl learned that the time-consuming part are the wind-up steps.
A solution to puzzle can be described as a sequence of instructions where is either “L” or “R” and describes that should be reached by applying only left (”L”) or only right (”R”) rotations from the previous position.
Given such a solution, compute the number of wind-up steps.
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 total number of wind-up steps.
Input:
4 1 10 3 R 1 10 3 L 2 10 3 8 RL 5 1000000000000 0 1 1 9 5 RLRLR
Output:
Case #0: 3 Case #1: 7 Case #2: 5 Case #3: 1999999999991
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.
Being equipped with a way to calculate the cost of solutions, Mouse Stofl now tries to find the optimal way to solve the puzzles.
First, he is starting on beginner puzzles: all positions are given in increasing order.
What is the minimal number of wind-ups required to solve the puzzle?
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 a single integer: the minimal total number of wind-up steps to solve this puzzle.
Input:
3 3 5 1 2 3 4 8 1 3 3 7 1 10 9
Output:
Case #0: 3 Case #1: 4 Case #2: 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.
The advanced puzzle pack contains puzzles with arbitrary positions, but only up to .
Can you help Stofl compute the minimal number of wind-ups to solve those?
Same as subtask 2.
Input:
2 5 7 4 0 2 4 6 11 3 2 1 2 0 2 1 2 0 2 1 2
Output:
Case #0: 7 Case #1: 6
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 Stofl thinks he’s able to tackle the expert puzzles: Arbitrary positions and up to of them!
Can you help Stofl one more time?
Same as subtasks 2 and 3.
Note that all but at most 30 test cases in this subtask also satisfy .
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).
While taking a stroll around Kékes, the tallest mountain in Hungary, Mouse Binna has found a nice slope. Unfortunately, there are no boulders on this slope. In order to rectify the situation, Mouse Binna would like to place some boulders in a nice pattern.
The slope is a grid with rows and columns. Immediately to the left of each row and on top of each column, there is an arbitrarily big supply of boulders. The slope is slanted such that Mouse Binna can easily push boulders to the right or downwards.
More precisely, Mouse Binna can place boulders by executing a sequence of steps. In each step, Mouse Binna can select either a row or a column:
Note that boulders can never change their direction of movement. As soon as a boulder is moving, Mouse Binna will not be able to stop it until it hits the bottom of the slope or it touches another boulder. Furthermore, once a boulder has stopped rolling, Mouse Binna will not be able to move it again.
Given some nice boulder patterns, determine if Mouse Binna is able to place those patterns on the slope. If it is possible, you should also provide a valid way to place the boulders.
The first line contains the number of test cases . test cases follow in the following format:
For the -th test case (zero-based), print a line “Case #i:” followed by the string “No” if Mouse Binna cannot place the boulders in the given nice pattern or “Yes” if Mouse Binna can do it.
In case it is possible, further print a number of lines equal to the number of boulders in the grid. The -th such line is either the character “R”, followed by a row index between and or the character “C”, followed by a column index between and . Columns are numbered from left to right and rows are numbered from top to bottom. Pushing a boulder down the specified rows and columns in the order printed in the output must result in the given nice pattern.
Note that there can be multiple ways to obtain the given nice pattern, in such a case you can print any one of them.
In all subtasks: - There are test cases. - In all but at most test cases, we have . - In all but at most test cases, we have . - In all but at most test cases, we have . - In all testcases, we have .
In this subtask, we have the additional constraint that . I.e., there is only a single row. Note that this additional constraint means that it is always possible for Mouse Binna to place the boulders in any given pattern. Therefore, you have to print “Yes” for all test cases.
From , it follows that .
Input:
3 1 1 . 1 1 # 1 4 #.##
Output:
Case #0: Yes Case #1: Yes C 0 Case #2: Yes C 3 R 0 C 0
Comment:
The first line with “3” indicates that there are three test cases.
Case #0: The grid has row and column and Mouse Binna does not have to place any boulders.
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, we have the additional constraint that , i.e., there are exactly two rows. Note that for , there are patterns that Mouse Binna cannot build. For such patterns, you should print “No”.
Input:
3 2 2 .# ## 2 2 #. .. 2 4 #.## ##..
Output:
Case #0: Yes C 1 C 1 R 1 Case #1: No Case #2: Yes R 0 R 0 C 0 C 0 C 1
Comment:
The first line with “3” indicates that there are three test cases.
Case #0: The grid has rows and column and Mouse Binna has to place three boulders. The solution first rolls a boulder down column . The boulder stops at the bottom of the grid. It then rolls another boulder down column . The boulder is stopped immediately by the other boulder and we fill up column entirely. Finally, Mouse Binna lets a boulder roll down row , which is stopped immediately, also by the first boulder.
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.
Let be the number of boulders that we have to place. In this subtask, we have no further constraints on and , but it is guaranteed that .
Input:
3 3 3 .#. ### ... 3 4 ##.. .##. ..## 4 5 ##... .#### ..#.# ....#
Output:
Case #0: Yes R 1 R 1 C 1 R 1 Case #1: Yes R 2 R 2 C 2 R 1 C 1 R 0 Case #2: 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.
In this subtask, there are no further constraints. I.e., we have and , where is the number of boulders we have to place.
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).
You are playing a card game against Mouse Stofl. Initially, both of you have cards. Each card has a number between and printed on it, and there is exactly one card of each number. The game has turns. In each turn, both players play one of their remaining cards, and the one who played the higher value wins the turn. You already know the order in which Mouse Stofl is going to play his cards.
In this subtask, you want to figure out whether you can win all turns, and if yes, in what order you can play your cards to achieve this. If you can’t win all turns, you don’t care how many turns you win.
The first line contains the number of test cases . test cases follow in the following format:
The first line of the test case contains , the number of cards of each player. A second line follows with integers , Mouse Stofl’s card values in the order he’s going to be play them. A third line follows with integers , your own card values in an arbitrary order.
For the -th test case, output a line “Case #i: M”, where M is “No” if you can’t win all turns, otherwise “Yes” followed by integers separated by spaces , the values of your cards in the order you’re going to play them.
There are test cases. In every test case, .
Input:
4 3 2 0 3 1 5 4 1 0 1 1 1 0 3 2 1 3 0 5 4
Output:
Case #0: Yes 5 1 4 Case #1: Yes 1 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.
In this subtask, you want to lose as many turns as possible. Can you figure out the lowest number of turns you win if you play as badly as possible? Note that you don’t need to print the order you play the cards anymore.
The first line contains the number of test cases . test cases follow in the following format:
The first line of the test case contains a single integer: , the number of cards of each player. A second line follows with integers , Mouse Stofl’s card values in the order he’s going to play them. A third line follows with integers , your own card values in an arbitrary order.
For the -th test case, output a line “Case #i: M”, where is the smallest possible number of turns that you can win.
There are test cases. In every test case, .
Note that all but at most test cases in this subtask also satisfy .
Input:
3 3 2 0 3 1 5 4 1 0 1 1 1 0
Output:
Case #0: 2 Case #1: 1 Case #2: 0
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, each of your own cards now also has a score attached. A score is a positive integer, and your total score at the end of the game is the sum of the scores of the cards that you played in the turns that you win. Note that Mouse Stofl’s cards don’t have scores in this subtask. Your goal is to maximize your total score.
The first line contains the number of test cases . test cases follow in the following format:
The first line of the test case contains , the number of cards of each player. A second line follows with integers , Mouse Stofl’s card values in the order he’s going to play them. A third line follows with integers , your own card values in an arbitrary order. A fourth line follows with integers , the scores of your cards. (The -th card has value and score ).
For the -th test case, output a line “Case #i: M”, where is the largest possible total score that you can achieve.
There are test cases. In every test case, . All scores are .
Input:
2 3 2 0 3 1 5 4 3 2 1 3 1 3 4 0 2 5 11 3 7
Output:
Case #0: 6 Case #1: 10
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, Mouse Stofl’s cards have scores, and your cards don’t. Your total score at the end of the game is the sum of the scores of the cards that Stofl played in the turns that you win. Your goal is still to maximize your total score.
The first line contains the number of test cases . test cases follow in the following format:
The first line of the test case contains , the number of cards of each player. A second line follows with integers , Mouse Stofl’s card values in the order he’s going to play them. A third line follows with integers , the scores of Stofl’s cards. (The -th card has value and score ). A fourth line follows with integers , your own card values in an arbitrary order.
For the -th test case, output a line “Case #i: M”, where is the largest possible total score that you can achieve.
There are test cases. In every test case, . All scores are .
Note that all but at most test cases in this subtask also satisfy .
Input:
2 3 2 1 4 4 1 1 0 5 3 3 2 3 5 11 3 7 0 1 4
Output:
Case #0: 5 Case #1: 11
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 final subtask, all cards have scores. Your total score at the end of the game is the sum of the scores of the cards played by you and by Stofl in the turns that you win. Your goal is still to maximize your total score.
The first line contains the number of test cases . test cases follow in the following format:
The first line of the test case contains , the number of cards of each player. A second line follows with integers , Mouse Stofl’s card values in the order he’s going to play them. A third line follows with integers , the scores of Stofl’s cards. (The -th of Stofl’s cards has value and score ). A fourth line follows with integers , your own card values in an arbitrary order. A fifth line follows with integers , the scores of your cards. (The -th of your cards has value and score ).
For the -th test case, output a line “Case #i: M”, where is the largest possible total score that you can achieve.
There are test cases. In every test case, . All scores are .
Note that all but at most test cases in this subtask also satisfy .
Input:
2 3 2 1 4 4 1 1 0 5 3 7 2 3 3 0 3 5 11 3 7 1 2 4 5 2 1
Output:
Case #0: 10 Case #1: 20
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).
Below Buda castle in Budapest lies the Palatinal Crypt, a burial place of several Archdukes and Archduchesses from the Habsburg dynasty.
The crypt consists of several rooms that are arranged in an grid. When the crypt was constructed initially, the rooms were sealed off.
To celebrate the crypt’s 255th birthday, the Hungarian state wants to open up the crypt to the public. For that, some walls should be removed such that all rooms inside the crypt become connected. To preserve the crypt, this should be done by removing strictly less walls than there are rooms.
Furthermore, out of respect to the buried, no room should have all 4 walls removed.
The government has hired Stofl to come up with some plans to satisfy all those constraints. However Stofl can’t find a solution either so he needs your help.
The government wants to try out this plan in one of the newer wings of the crypt, the Klotild wing.
Can you help Stofl find a valid solution?
The first line contains a single integer , the number of test cases.
lines follow, each with two integers and : There are rooms.
For the -th test case, print a line “Case #i:”
This should be followed by an ASCII representation of the crypt with some walls removed. A description of such a representation follows, but it might be easier to look at the examples below.
Input:
2 3 3 4 3
Output:
Case #0: o.o.o |.|.| o-o-o |...| o-o.o Case #1: o-o-o ..|.. o-o.o |...| o-o-o ..|.| o-o.o
The following is an example of invalid output
Input:
3 3 3 3 3 3 3
Output:
Case #0: o-o-o ..|.. o-o-o ..|.. o-o-o Case #1: o-o-o |...| o.o-o |...| o-o-o Case #2: o-o.o |...| o.o.o ..|.| o-o-o
Comment:
All of those outputs are incorrect. The following paragraphs explain why:
In Case #0, the room in the center of the grid has all four walls removed.
In Case #1, more walls are removed than allowed.
In Case #2, the network is not connected. For example, you can’t get from the top left room to the top right room.
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 following example should help you understand some of the automatic feedback you might receive. Click on the box below to see it.
After further investigation, the government also does not want to have rooms that have exactly 2 walls removed. This demotes the room into a passage which does not pay the proper respect for a burial site.
Stofl does not believe this is possible. Can you show him some examples where this is indeed possible?
The first line of input is , the number of crypt layouts you should output. This number is always 20.
This will be followed by lines containing the indices of the testcases, i.e. the first line contains the number , the second line the number etc.
Note that your program doesn’t actually have to read any input since the input file will always be the same.
Output twenty crypt layouts. For the -th crypt, output Case #i: N M with some integers and of your choice: The height and width of the crypt. After that, output the crypt itself like in Subtask 1. It should have rooms.
No two crypts may have the same width and the same height. It is, however, allowed to output any number of crypts with the same width or the same height.
Input:
2 0 1
Output:
Case #0: 1 2 o-o Case #1: 2 3 o-o-o ..|.. o-o-o
The following is an example of invalid output
Input:
3 0 1 2
Output:
Case #0: 3 3 o.o.o |.|.| o-o-o |...| o-o.o Case #1: 1 2 o-o Case #2: 1 2 o-o
Comment:
In Case #0, the bottom left room has exactly two walls removed. This is no longer allowed in this subtask, but would have been allowed in Subtask 1.
Case #1 and Case #2 would be OK by themselves, but they use the same width and height.
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.
Since you’ve convinced Stofl that there are some crypt sizes where the constraints from Subtask 2 can be satisfied, he now wants you to do the same for some other sizes.
Same as Subtask 1.
For the -th crypt, print a line “Case #i: Possible” or “Case #i: Impossible”, depending on whether it is possible to remove some walls from a crypt in order to satisfy all constraints
If it is possible, output the ASCII representation as in Subtasks 1 and 2.
Same as Subtask 1.
Input:
3 1 2 2 2 2 3
Output:
Case #0: Possible o-o Case #1: Impossible Case #2: Possible o-o-o ..|.. o-o-o
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.
Note that the automatic grader will not tell you if you wrongly answer “Possible”. It will only point out why your output is not a solution. This can either mean there is a solution, but you did something wrong, or it can mean there is no solution.
Your designs got so much praise that other crypts around the world want to implement a similar scheme. Because Mouse Stofl does not have the time to respond to every request, he wants you to create a well-documented instruction manual so that everybody can figure out which walls to tear down by themselves.
This is a theoretical subtask. Describe an algorithm that can solve subtask 3 and prove its correctness.
Hand in a document (preferably PDF) that describes
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).
Hungary is home to a huge variety of thermal water springs, each with different water temperatures, mineral contents or smell. Some springs even come with some nice panorama. Mouse Binna plans to hike around in Hungary and bathe at many different springs. In order for her trip to end on a high note, she wants every spring to be strictly better than the previous: each thermal spring should have a higher water temperature, a higher mineral content, less sulfur smell and more scenery than the previous spring.
Binna has already asked the local wood mice about the various upsides and downsides of each spring. Can you help her plan her trip?
For her first trip, Binna wants to bathe at all the springs near Szeged, Hungary. Can you help her find a route to do so, or tell her this is not possible?
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 #t:” followed by “YES” or “NO”, depending on whether Binna can bathe at all the springs. If the answer was “YES”, then print a single line with integers – the order in which Binna can bathe at the springs. (Springs are numbered from to .)
Input:
4 2 2 1 2 1 1 2 2 1 2 1 2 1 2 1 2 1 2 3 9 4 7 8 2 3 12 44 13 5 1 4 3 1 1 1 2 2 2 3 3 3 4 4 4
Output:
Case #0: YES 1 0 Case #1: NO Case #2: YES 1 2 0 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.
After realizing that she sometimes couldn’t bathe at all the springs, Binna was about to give up on her hike, but then she had an idea: what if she instead tried to bathe at as many springs as possible? Can you help her plan her trip?
Same format as subtask 1.
For the -th test case print a line “Case #t:” followed by an integer – the maximum number of springs Binna can bathe at while ensuring that every spring is better then the previous. On the next line print integers – the springs Binna bathes at, in order. If there are multiple optimal solutions, you may print any one of them.
Input:
4 2 2 1 2 1 1 2 2 1 2 1 2 1 2 1 2 1 2 3 1 1 1 2 2 2 3 3 3 4 4 4 3 4 1 8 2 3 8 9 8 7 1 5 6
Output:
Case #0: 2 1 0 Case #1: 1 0 Case #2: 1 1 Case #3: 2 1 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.
Bathing at this many spring was a lot of fun, but Binna still has nagging thoughts about not having bathed at all the springs. She’s planning another trip to Hungary, but this time, she invited mouse Stofl to come with her. Stofl also likes to bathe and he too wants every spring to be better than the previous one.
The plan is to hike on different routes such that every spring will be bathed at by exactly one mouse. Can you help them plan their trip?
Same as in subtask 1.
For the -th test case print a line “Case #t:” followed by “YES” or “NO”, depending on whether Binna and Stofl can find two routes such that every spring will be bathed at by exactly one mouse. If the answer was “YES, then print two more lines. The first line should contain the springs Binna bathes at, it order, and the second line should contain the springs Stofl bathes at, in order. (Springs are numbered from to .)
Input:
4 2 1 2 1 2 1 2 1 2 2 2 1 2 1 1 2 2 1 3 1 1 1 2 2 2 3 3 3 4 4 4 3 4 1 8 2 3 8 9 8 7 1 5 6
Output:
Case #0: YES 1 0 Case #1: YES 1 0 Case #2: NO Case #3: YES 0 2 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.
Together, Binna and Stofl bathed at every thermal spring near Szeged. Now, they have bigger plans: they want to bathe at every single thermal spring in Hungary. Those are a lot of springs, so you better help them find good routes!
Same as in subtask 1.
Same as in subtask 3.
Note that all but at most test cases in this subtask also satisfy the limits of the previous subtask.
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 famous Dada artist Mouse Stofl is making a new artwork right inside the famous “Budavári Labirintus” labyrinth in Budapest. The labyrinth has rooms connected with two-way passages in such a way that it is possible to get from any room to any other room. In other words, the rooms and passages form a tree. The rooms are numbered from to , and the -th passage connects rooms and .
The artwork consists of paintings, one in each room. Mouse Stofl has already placed a big white canvas in each of the rooms.
Mouse Stofl has also bought buckets of paint of pairwise different colors numbered from to and placed them strategically: the bucket of paint with color is in the room .
For each of the paintings, Mouse Stofl knows which colors need to be applied to it, but he does not care in particular in which order this will happen. More specifically, the painting in the -th room needs different colors applied: , in any order. It is possible that some paintings need to be left untouched (), or that some colors are not needed on any painting.
Mouse Stofl can move between the rooms using the passages either empty-handed or carrying at most one bucket with paint, since those are quite heavy. In order to apply a color to the painting in a room, Stofl needs to bring the corresponding bucket there. Since the buckets are going to be part of the artwork as well, in the end each bucket needs to be brought back to the room where it was in the beginning: the bucket of paint with color needs to end up in room .
Mouse Stofl does not like to carry heavy buckets around. Can you help him find the minimum number of times he needs to carry a bucket of paint along a passage in order to complete the artwork?
In this subtask all paintings either require no paint at all, or require only color .
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 equal to the minimum number of times Stofl needs to carry a bucket of paint along a passage in order to apply all required colors to each painting and then bring each bucket to its original location.
Input:
1 3 0 1 1 2 1 0 1 0 0
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.
In this subtask the paintings may require an arbitrary number of colors.
Same as subtask 1.
Input:
1 3 0 1 0 2 0 2 2 1 2 2 0
Output:
Case #0: 6
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, apprentices will be helping Mouse Stofl complete the artwork. Since apprentices are not yet artists, Stofl can only give them a limited type of tasks.
More specifically, for each color , Stofl will meet the apprentices in room where the bucket with this color is initially placed, and pour some paint of this color into smaller buckets. He will then give some (possibly none or all) apprentices one smaller bucket each, and send them through different passages going from this room. Each apprentice will visit all rooms that they can reach before going back to room , and apply the color to the paintings in those rooms if necessary. But as soon as an apprentice gets back to room , they pour the remaining contents of their small bucket back into the big bucket with color , and they do not want to work with this color anymore.
This process is repeated for each color. Note that even though Mouse Stofl can carry the big buckets around, he will not move the bucket with color before the apprentices are done with color , to avoid confusion. Therefore the apprentices carrying color are always sent out from room .
Note that if the number of passages connected to room is greater than , some rooms will not be visited by apprentices carrying color , and therefore Stofl might still have to carry the big bucket there himself to apply this color to the painting. In that case he still needs to bring the bucket back to room at the end.
For each color , Mouse Stofl is free to choose up to passages going from room that he will send apprentices through in any way. His goal is still to minimize the number of times he needs to carry a bucket through a passage himself.
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 equal to the minimum number of times Stofl needs to carry a bucket of paint himself along a passage in order to apply all required colors to each painting and then bring each bucket to its original location.
Input:
1 8 2 0 1 1 2 0 3 4 2 2 5 4 6 5 7 3 7 2 4 0 8 0 1 2 3 4 5 6 7 5 2 3 4 5 6 1 2 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 1 2
Output:
Case #0: 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.
In this subtask everything is as in subtask 3, but bigger.
Same as subtask 3.
Note that all but at most test cases in this subtask also satisfy the limits of the previous subtask.
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.
You need to analyze how big the answer in this problem can be depending on the values of and .
More specifically, we define as the maximum possible number of times Mouse Stofl needs to carry a bucket along a passage for any possible input with rooms and apprentices. You need to provide an upper bound and a lower bound for , expressed as formulas with two variables and , and prove those formulas.
You can consider that and , but note that unlike all previous subtasks, there is no upper limit on , or . Your formulas have to cover all possible options for paintings in rooms. The proof for the lower bound will typically involve demonstrating an example input achieving this lower bound for each given and , while the proof for the upper bound needs to consider all possible inputs.
For both bounds, we do not care about a constant factor: for example the formulas and , or any two formulas such that their fraction is bounded by some constant from above and by some positive constant from below, will get the same number of points. In other words you can use the big-O notation for the upper bound and the big-Omega notation for the lower bound. You can read more about those notations in https://soi.ch/wiki/algorithms-intro/.
For example, and would be a valid answer to this subtask (which you would still need to prove, even if it is not very hard), but it will not give you any points as these are not very tight bounds. and would be another valid way to write this using the big-O and big-Omega notations.
You are free to write down your formulas in any way you like, for example you can also write things like if , or if .
Hand in a document (preferably PDF) that contains
If your proofs are correct, we will give you the points based on how close are the values computed using your formulas to the real value of . The smaller the upper bound is (notwithstanding a constant factor), and the bigger the lower bound is (again notwithstanding a constant factor), the more points you will get.
10 points will be allocated to the lower bound, and 30 points will be allocated to the upper bound.
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).
Mouseland got a new subway system thanks to you! One of the subway lines leads out of the city into a newly created nature reserve. Mouse Binna and mouse Stofl were tasked with reforestation of the area to make it more pleasurable for the mice to spend time there.
Unfortunately, Binna and Stofl can’t agree on which type of forest they should plant. While Binna is convinced that the population of Mouseland would prefer oak trees, Stofl thinks they should plant pine trees. As they did not reach a conclusion after hours of discussion, they decided to turn it into a game. Help one of them to win and establish either oak trees or pine trees as the dominant tree in the nature reserve.
The nature reserve is split into multiple points of interest with bidirectional trails between them. Each node has some fertility and some attractiveness . Initially, there are no trees in the nature reserve.
At the start of the game, the two players are assigned a starting node each. They both plant their type of tree on this node. Once there is some type of tree on a node, the player who is planting this type of tree owns the node. A node will never change the type of tree growing on it once some type of tree grew on it.
Afterwards, the game proceeds in rounds. In each round, a player gets some number of saplings equivalent to the sum of fertility of all the nodes the player owns. Each player can then distribute some or all of its saplings onto empty nodes. Unused saplings can be saved up for future rounds. After the saplings were placed, each node is evaluated in parallel as follows:
The game ends once all nodes have trees on them or after 2’000 rounds. The player with the higher sum of attractiveness of their nodes wins.
The communication between program and server is handled using Stdin / Stdout.
At the start the program receives general information about the game:
One line with , the number of nodes , the number of paths , your starting node , and the starting node of your opponent. On the next line there are space separated integers , the fertility of the -th node. On the next line there are space separated integers , the attractiveness of the -th node. lines follow with two space separated integers each, denoting a path between node and .
Now the game starts. For each round you first get two space separated integers , the number of saplings you have available and the number of saplings your opponent has available in this round. Then you have to print one line with space separated integers , the number of saplings you want to plant on node . You will then receive lines with two integers , the number of saplings your opponent placed on the -th node in this round, and the owner of the -th node: for your opponent, for no owner, and if you are the owner.
After the last round you will receive a final line with (i.e. for both and ). Your program should exit.
These limits apply for all maps and are therefore very general. Take a look at the maps section to get a better idea of the kind of maps you can expect.
We aim for , but due to some randomness in the map generation it is possible that there are a few more nodes.
It is guaranteed that there exists some sequence of trails to get from every node to every other node.
Open the example in the visualization
The map before the start of the game. Attractivity is displayed in yellow, fertility in green.
The moves of the first round. Both have planted the same number on the node in the middle right, so nobody gets it.
The map after the first round. Red has spent all saplings, blue still has one left.
The moves of the second round. Even tough red only put three saplings on the node in the middle right, and blue put 4, red gets the node, because for blue 3 are lost on the way.
The map at the end of the game. Red has the higher sum of attractiveness, and with that wins the game.
Here is the communication from the point of view of the red player. The input of the program is marked with “<”, and the output with “>”.
< 6 6 0 5 < 5 3 10 0 3 5 < 0 0 372 584 310 0 < 0 1 < 1 2 < 1 3 < 2 3 < 3 4 < 4 5 < 5 5 > 0 1 0 4 0 0 < 0 1 < 0 1 < 0 0 < 4 0 < 0 0 < 0 -1 < 8 6 > 0 0 3 3 0 0 < 0 1 < 0 1 < 0 1 < 4 1 < 1 -1 < 0 -1 < -1 -1
The creativity task will take place on the creativity platform. There you can create new bots, upload the source code for your bots, play games against other participants (or your own bots), view the results of tournaments, and see a ranking of all bots. If you have any questions about the platform do not hesitate to ask us.
A few notes about the platform:
Write a bot that follows the rules and can beat the example bot. Just play and win any game against the random bot on the creativity platform. We have to manually update the scores, so it might take a few days until they show up on the round 1 ranking.
Write a bot which is able to beat our smart bot. Play and win games on at least 5 different map layouts against the smart bot on the creativity platform. You may choose the other map parameters freely. We have to manually update the scores, so it might take a few days until they show up on the round 1 ranking.
You play against other participants of the SOI in multiple tournaments. Based on the rankings of these you will get points.
Each tournament is worth a certain amount of points and you will get a fraction of these based on your rank: 100% for rank 1, then 10% less for every following rank until rank 6 (50%), then 5% less for every following rank. We only include the best bot for each participant in the ranking. However, the creativity platform does not exclude multiple bots from the same person, so the points you receive might not match the displayed ranking.
In the end, your score for this subtask will be the maximal score you achieved during any tournament. There will be the following tournaments:
We will update the scores on the round 1 ranking after every tournament, but as we do this manually it might take a few days.
On the creativity platform you can view additional details about the tournaments. A tournament consists of multiple map configurations. For each configuration you will play against every other bot. Each configuration has a score weight associated with it. For a win on a map you will get , for a draw and for a loss score. The ranking will be according to the sum of these scores across all played games.
There are a few different map configurations on which we will run the bots. A configuration consists of the following parameters:
It is important for interactive tasks to flush the output buffer after every turn to make sure the server can see your output.
Use the following commands:
Furthermore it is important that you don’t wait for more characters than the server gives you as an input. For example spaces or line endings in C format strings are a common source for errors. For example if you read the last variable in the input with “scanf("%d ", &x);” it will wait for the next character that is not a space or a line break. You will receive such a character only after you printed your next turn. To solve this use “scanf("%d", &x);” instead (no non-printable characters after the “%d”).
If you want to run your bots locally you can download the judge and the visualization here. This also includes a sample C++ bot. The judge and the visualization both include a short explanation on how to run them. They are the exact same version which is used on the creativity platform, except for some additional sandboxing for the bots.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Rank | Username | Total (500) | paragli… (100) paragliding | rubiksknob (100) | boulders (100) | cardgame (100) | palatin… (100) palatinalcrypt |
---|---|---|---|---|---|---|---|
loading ... |
Rank | Username | Total (600) | boulders (100) | cardgame (100) | palatin… (100) palatinalcrypt | thermal… (100) thermalsprings | dada (100) | trees (100) |
---|---|---|---|---|---|---|---|---|
loading ... |
Case #0: We cannot glide from the first place to the second place since its height is lower, thus no trip is possible and the distance is 0. Since the second place is higher than the first we can fly from the second place to the first place, the distance of this trip is 2.
Case #1: Here since the first place is higher than the second we may fly from the first to the second with a distance of 639 meters, flying over the steep face directly below the take-off site at the Uetliberg. However we cannot fly from the second to the first so the distance is 0.