Welcome to the Second 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.
Contest ends at 2025-11-30T23:59:59+01:00
Category | Task | Total | Subtask 1 | Subtask 2 | Subtask 3 | Subtask 4 | Subtask 5 | Subtask 6 | Subtask 7 |
---|---|---|---|---|---|---|---|---|---|
Junior only | registanpattern | ‒/100 | ‒/11 | ‒/17 | ‒/29 | ‒/43 | |||
Junior only | timuridriders | ‒/100 | ‒/8 | ‒/9 | ‒/14 | ‒/18 | ‒/24 | ‒/27 | |
Both | mousedances | ‒/100 | ‒/6 | ‒/12 | ‒/15 | ‒/13 | ‒/18 | ‒/14 | ‒/22 |
Both | fire | ‒/100 | ‒/12 | ‒/19 | ‒/21 | ‒/22 | ‒/26 | ||
Both | roborbuy | ‒/100 | ‒/10 | ‒/15 | ‒/10 | ‒/25 | ‒/40 | ||
Both | bukhara | ‒/100 | ‒/7 | ‒/15 | ‒/18 | ‒/27 | ‒/33 | ||
Regular only | tombexploration | ‒/100 | ‒/17 | ‒/18 | ‒/24 | ‒/41 | |||
Regular only | evilruins | ‒/100 | ‒/6 | ‒/10 | ‒/19 | ‒/8 | ‒/14 | ‒/43 | |
Regular only | 2h | ‒/100 | ‒/25 | ‒/25 | ‒/25 | ‒/25 |
You may use any programming language to solve the tasks of the Second Round. To solve a practical task, you have to design a program, download an input file, run the program on the data in that file, write the results in another file and upload it along with the source code to the website, which will grade your submission and display the number of points that you’ve earned as well as an explanation if you did not get all the possible points. In order to read the data in the input file, make sure that your program either reads directly in that file or redirect the standard input to it (in a terminal running on Linux, Windows or macOS, you can do that by using the command ‘yourprogram < inputfile’, replacing ‘yourprogram’ and ‘inputfile’ by the paths to the actual program and input file). More elaborate explanations about how to solve the tasks of the Second Round await you on our wiki and our training page. Note that in case you get stuck on the tasks, you can move to next task and try again later: no need to solve them in order.
You should also hear about our workshops! In October and November, we offer workshops about algorithmics. It’s a great opportunity to learn all you need for the Second Round and to meet other like-minded participants. Whether you’re a beginner or an experienced programmer, it’s worth it to come. More info and registration here.
Don’t hesitate to contact us at info@soi.ch if you have any question about programming or the tasks.
To participate, you need to either have qualified in the first round or scored 500 points in the pre-round. It may take up to five minutes after adding an additional email address in your profile or submitting something in the pre-round for your qualification status to be updated.
The Second Round has two categories: Junior and Regular. You can participate in the Junior category if you are eligible to participate in this year’s edition of SOI as well as the two next ones. If you are eligible as a junior, you can choose to participate in the Junior or in the Regular category or in both.
You qualify for the finals and the Sarnen Camp if you are placed under the
Additionally, we may distribute wildcards.
We wish you good luck, hope you will enjoy solving our tasks and look forward to meeting you at our workshops.
Mouse Stofl and Mouse Binna have finally made it to Uzbekistan’s beautiful registans, which are full of colorful patterns.
Stofl found similarities in the patterns of the registan and he became artistically inspired! Although this time, Stofl had a way too crazy idea.
They came to a wall which is one meter tall and several meters long. The inspiring characteristics of the wall was its modular design every meter. Stofl’s idea was to cut the wall into one meter parts in order to rearrange them, which results in a new but still continuous pattern. However, Binna disliked his idea very much. She doesn’t care about the building itself, but she doesn’t like the lack of innovation. She thinks just rearranging the patterns is boring, so she gave him the challenge to make a unique pattern by dividing the wall into segments of several meters and then flipping all the segments in place.
However, Stofl has already assigned for each meter the position it should go. To impress Binna, he needs to find out how he can divide the wall such that he achieves his original vision by flipping the segments.
Stofl has a wall which is meters long. Can you help him determine how he should divide the wall?
The first line contains the number of test cases . For every test case, two lines will follow:
For the -th test case, if it is not possible to achieve Stofl’s assignment by flipping segments, print “Case #t: Impossible”. Otherwise, print “Case #t: Possible” and two additional lines:
Input:
2 3 0 2 1 3 2 0 1
Output:
Case #0: Possible 2 1 2 Case #1: Impossible
Solution for Case #0:
Dividing the wall into these two segments achieves that each meter of the wall ends up where Stofl wants it. Meter 1 is flipped by itself and thus remains where it is, while meters 2 and 3 are swapped.
To submit for this subtask, please log in.
The walls at the entrance are up to meters long! Can you still help Stofl?
Same as subtask 1.
Same as subtask 1.
Input:
3 3 1 0 2 5 1 0 4 3 2 6 2 1 5 4 3 0
Output:
Case #0: Possible 2 2 1 Case #1: Possible 2 2 3 Case #2: Impossible
To submit for this subtask, please log in.
The registan is huge! Despite that, the patterns have still the same characteristics everywhere. Stofl would be overjoyed if you could help him out on this ambitious task.
Same as previous subtasks.
Same as previous subtasks.
Binna wasn’t impressed so far. So if this didn’t impress Binna, surely he needs to go even bigger than that and combine all walls of every registan in Uzbekistan.
Same as previous subtasks.
Same as previous subtasks.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
During the late Middle Ages, Uzbekistan was the heartland of the Timurid Empire, stretching from central Anatolia all the way to northern India, with Samarkand as its capital.
Binnas Birthday is coming up, and Mouse Stofl wants to prepare a special surprise for her. He knows that she is fascinated by the history of the Timurid Empire, and that she loves puzzles. So he came up with a puzzle based on the Timurid Empire.
The Timurid Empire in the puzzle consists of villages, including the capital, and roads between them, on which riders can travel. The capital Samarkand is always village . The villages bordering the wilderness have watchtowers to guard the borders. These villages can be recognized because they have exactly one road leading out and are not the capital. All other villages, including the capital, contain fortresses.
The puzzle further follows these rules:
The goal is to decide from which watchtower to release each rider, and in what order, so that every fortress in the empire is manned in the least possible total time.
Stofl asked you to solve the puzzle, so that he can see if it is fit for Binna.
To test your understanding of the rules, Mouse Stofl wants you to predict which fortress each rider will stop at, given a list of dispatch orders.
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: r_0 r_1 ... r_{M-1}”, where is the city in which rider will halt.
There are test cases. In each test case we have:
Input:
3 3 0 1 0 2 2 1 2 3 0 5 1 3 3 2 2 2 6 4 1 0 1 2 3 0 2 2 5 3 3 1 3
Output:
Case #0: 0 2 Case #1: 0 1 2 Case #2: 0 4 2
Comment:
Disclaimer: Generation may take a few seconds.
To submit for this subtask, please log in.
Being satisfied that you understood the rules, Mouse Stofl will first give you an easier version of the puzzle, taking place along a caravan trail from the furthest away village all the way to Samarkand. In this version, there is exactly one capital and one village with a watchtower. All other villages have exactly one road leading in and one leading out.
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: K”, where is the minimum total time required to man every fortress.
There are test cases. In each test case we have:
Note: You may exceed the maximum recursion depth.
Input:
3 3 0 1 1 2 2 0 5 4 0 3 1 2 2 4
Output:
Case #0: 5 Case #1: 5 Case #2: 19
Comment:
Disclaimer: Generation may take a few seconds.
To submit for this subtask, please log in.
Next, Mouse Stofl gives you a map centered around Bukhara. The unique feature is that all roads have length .
Same as Subtask 2
Same as Subtask 2
There are test cases. In each test case we have:
Input:
3 3 0 1 0 1 4 0 1 3 1 0 1 6 4 1 0 1 2 1 0 1 2 1
Output:
Case #0: 1 Case #1: 2 Case #2: 4
Disclaimer: Generation may take a few seconds.
To submit for this subtask, please log in.
In this subtask, Mouse Stofl gives you a map of the surroundings of Shahrisabz. The unique feature is that the capital has the same distance to every watchtower.
Same as Subtask 2
Same as Subtask 2
There are test cases. In each test case we have:
Input:
3 3 0 3 0 3 4 0 3 3 2 0 1 6 4 1 0 1 2 2 0 2 2 2
Output:
Case #0: 3 Case #1: 5 Case #2: 6
Disclaimer: Generation may take a few seconds.
To submit for this subtask, please log in.
In this subtask, Mouse Stofl gives you a map of a small portion of the Timurid Empire, with a small number of villages and roads.
Same as Subtask 2
Same as Subtask 2
There are test cases. In each test case we have:
Input:
3 3 0 1 0 2 2 0 5 6 4 1 0 1 2 3 0 2 2 5
Output:
Case #0: 1 Case #1: 5 Case #2: 7
Comment:
In the first testcase, it is best to dispatch the first rider from the watchtower in city , who will ride to village in hour.
In the second testcase, there is only one option: dispatching a rider from the watchtower in city .
Disclaimer: Generation may take a few seconds.
To submit for this subtask, please log in.
Mouse Stofl is now confident that you can solve the original puzzle with a map of the entire Timurid Empire.
Same as Subtask 2
Same as Subtask 2
There are test cases. In each test case we have:
Disclaimer: Generation may take a few seconds.
To submit for this subtask, please log in.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Mouse Stofl and friends are hosting a grand dance festival. All through the night, mice gather next to each other holding paws with their neighbors, swaying to the music, spinning in step, and pausing now and then for a nibble of cheese before the next melody begins.
But dancing is not always easy. When neighbors differ too much in height, their little paws strain with effort, their backs stretch or stoop too much and before long the mismatched neighbors grow tired and let go. The greater the height difference, the greater the inconvenience — and the sooner the dance floor empties.
To keep the celebration alive until sunrise, the mice must choose their places wisely: arranging themselves so that the maximum inconvenience between any two neighbors is as small as possible. Depending on the melody, they may form a line, gather in a circle, or even whirl apart into two circles — but always with the same goal: minimize the maximum inconvenience, and keep the dancing going through the night.
For each subtask, help Stofl arrange the mice for a different melody so that he can minimize the maximum inconvenience between neighbors.
All subtasks use the same input format:
The first line contains the number of test cases . For each test case you get two lines:
For all subtasks we have , and .
For the -th testcase, output a single line containing “Case #t: x” where is the smallest possible maximum inconvenience. For a given arrangement, the maximum inconvenience is defined as the maximum absolute difference between heights of adjacent mice. Then you may need to output additional lines depending on the subtask. (see each subtask’s “Output format”). When an arrangement is requested, it must be a permutation of the input heights.
The first melody is danced in a line. Help Stofl arrange a few mice in a line so that the maximum inconvenience is minimized.
Output two lines per test case: 1. A single integer — the minimal possible maximum inconvenience. 2. integers — a valid optimal arrangement (the order in the line).
Input:
2 2 2 1 3 1 5 2
Output:
Case #0: 1 2 1 Case #1: 3 1 2 5
To submit for this subtask, please log in.
The second melody is also danced in a line. Help Stofl arrange a larger group of mice in a line so that the maximum inconvenience is minimized.
The third melody is also danced in a line and it is such a popular song that not just Stofl’s village but several other villages march into the dance floor to join in. Help Stofl arrange a huge crowd of mice in a line so that the maximum inconvenience is minimized. To keep output small, output only the optimal value of inconvenience and not the actual arrangement.
Output one line containing a single integer — the smallest possible maximum inconvenience.
Input:
2 2 2 1 3 1 5 2
Output:
Case #0: 1 Case #1: 3
To submit for this subtask, please log in.
The fourth melody is danced in a circle, so that the last mouse is a neighbor of the first mouse. Arrange the mice so that the maximum inconvenience is minimized.
Output two lines: 1. A single integer — the minimal possible maximum inconvenience on the circle. 2. integers — a valid optimal circle order (print in a list; wrap-around is implied between last and first mouse).
Input:
2 2 2 1 6 8 5 6 10 10 9
Output:
Case #0: 1 2 1 Case #1: 3 5 8 10 10 9 6
To submit for this subtask, please log in.
The fifth melody is also danced in a circle, with a huge crowd of mice dance joining in. Arrange the mice optimally, and to keep output small, output only the optimal value of inconvenience and not the actual arrangement.
Output one line containing a single integer — the minimal possible maximum inconvenience.
Input:
2 2 2 1 6 8 5 6 10 10 9
Output:
Case #0: 1 Case #1: 3
To submit for this subtask, please log in.
To dance the sixth melody, the mice split into two circles, both non-empty. Arrange the mice in a way that minimizes the maximum inconvenience seen across the two circles.
Output four lines: 1. A single integer — the smallest possible maximum over the two circles’ maximum inconvenience values. 2. Two integers: — lengths of the two circles (both , ). 3. integers — a valid arrangement for the first circle 4. integers — a valid arrangement for the second circle
Input:
2 2 2 1 7 8 5 6 10 10 9 1
Output:
Case #0: 0 1 1 2 1 Case #1: 3 6 1 5 8 10 10 9 6 1
To submit for this subtask, please log in.
For the seventh melody, a huge crowd of mice split into two circles, both non-empty. Arrange them in a way that minimizes the maximum inconvenience seen across the two circles. To keep output small, output only the optimal value of inconvenience and not the actual arrangement.
Output one line containing a single integer — the smallest possible maximum over the two circles’ maximum inconvenience values.
Input:
2 2 2 1 7 8 5 6 10 10 9 1
Output:
Case #0: 0 Case #1: 3
To submit for this subtask, please log in.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Mouse Binna is on an adventure in a vast forest that is modeled as an grid. Lately, the weather has been extremely dry, and the forest is about to catch fire. Binna is located at the top-left corner of the grid , while an underground shelter lies at the bottom-right corner , offering safety from the fire.
At time , fire starts in distinct cells of the grid — these are called fire sources. At each unit of time, the fire spreads:
Binna wants to know the latest time such that a safe path exists from her current location to the underground shelter . Both endpoints and all cells on the path must not be on fire at time . Moves are allowed only in the directions: up, down, left, right. If no such path exists even at time , then .
At time , there is exactly one fire source.
The first line contains the number of test cases . test cases follow in the following format:
For each test case, output a line “Case #i: L”, where represent the latest time such that there still exists a safe path, or if no safe path exists even at time .
There are test cases. In each test case we have:
Input:
3 7 1 1 3 4 1 2 1 4 1 1 1
Output:
Case #0: 2 Case #1: 1 Case #2: 0
Comment:
To submit for this subtask, please log in.
All fire sources are in the same row.
Same as Subtask 1
Same as Subtask 1
There are test cases. In each test case we have:
Input:
2 7 3 4 0 4 1 4 3 20 2 15 2 15 6
Output:
Case #0: 2 Case #1: 12
Comment:
To submit for this subtask, please log in.
The grid size is limited.
Same as Subtask 1
Same as Subtask 1
There are test cases. In each test case we have:
Input:
3 8 3 1 7 5 1 7 2 7 3 3 4 0 2 6 3 4 4 2 0 2 1 1 2 1 3
Output:
Case #0: 3 Case #1: 1 Case #2: -1
Comment:
To submit for this subtask, please log in.
The number of fire sources is small.
Same as Subtask 1
Same as Subtask 1
There are test cases. In each test case we have:
To submit for this subtask, please log in.
Both the grid size and the number of fire sources are large.
Same as Subtask 1
Same as Subtask 1
There are test cases. In each test case we have:
To submit for this subtask, please log in.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
The Silk Road in Uzbekistan was a trade route, where merchants travelled to cities like Samarkand to exchange silk, spices and other goods. The many markets and caravans made it a center of commerce across Uzbekistan and other parts of Asia. It was a lively road with a lot of merchants and travelers, but also thieves and robbers!
On the road, there are merchants in a line, numbered from to . Each of them sells some goods. The goods of the -th merchant cost mouse coins. There is the myth of the “Silk Road’s great heist” in which the entire road was robbed in lightning speed! That’s why the merchants on the road created an alarming network to notify other merchants of an ongoing robbery. Each merchant is assigned a direction which is either for left, or for right. After a merchant is robbed, he will notice the robbery and alarm every merchant on his left or right respectively. Any merchant that is alarmed this way will pay extra attention and robbing the merchant becomes impossible.
Mouse Stofl wants to do the thievery himself and wants to get all the goods sold on the Silk Road. But since it’s impossible to steal from alarmed merchants, he will need to buy some of the goods. So the questions is, what is the minimum amount of money he needs to spend, if Stofl robs and buys the goods in the perfect order?
The first line contains the number of test cases . For each test case you get three lines:
For each test case, output a line Case #i: P, where is the minimum amount of money Stofl needs to spend to get all the goods.
There are test cases. For each test case, we have:
Input:
2 2 rl 3 5 3 lll 10 48 39
Output:
Case #0: 3 Case #1: 0
Comment:
To submit for this subtask, please log in.
The road is longer now, can you still answer Stofl’s question?
Same as subtask 1.
There are test cases. For each test case, we have:
To submit for this subtask, please log in.
Stofl doesn’t like merchants being alarmed. Therefore he will hire mercenaries to interrupt the alarms of the merchants. Between any two adjacent merchants, he can hire a mercenary to stop the alarms from spreading further. This will interrupt any alarm signal from passing, not only the alarms from the merchants next to the mercenaries.
The mercenaries are in dire need of money, so they offer their service for mouse coin. In this subtask it holds that .
On the first line on each test case, you will now get two spaced integers and , corresponding to the number of merchants and the price of hiring a mercenary. The rest of the input is the same as subtasks 1 and 2.
For each test case, output a line Case #i: P, where is the minimum amount of money Stofl needs to spend to get all the goods. also includes the amount Stofl spends on mercenaries.
There are test cases. For each test case, we have:
Input:
1 4 1 rrll 6 3 5 4
Output:
Case #0: 1
Comment:
To submit for this subtask, please log in.
The mercenaries between Samarkand and Bukhara do not offer their service for so cheap. Can you still answer’s Stofl question?
Same as subtask 3.
There are test cases. For each test case, we have:
To submit for this subtask, please log in.
Stofl wants to rob the entire Silk Road! There are a lot of merchants and the prices can get very high!
Same as subtask 3 and 4.
There are test cases. For each test case, we have:
To submit for this subtask, please log in.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Under construction, coming very soon*
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Shah-i-Zinda is a famous necropolis (a large old cemetary) in Uzbekistan. Mouse Binna and a large team of passionate archeologists are preparing to enter an old, cursed, and unexplored tomb to bring back all the valuable historical unseen items they can find for the local museum. This project is of the upmost importance as all previous tombs explored were scavenged centuries ago because no curse protected them.
The tomb’s cryptic curse is written in majestic carved letters above the entrance: “He who exits these sacred grounds, shall suffer the weight of his hefty theft.”
Fully prepared to endure the consequences of their actions for the historical sake of the country (the team is as passionate about history as you can get), the entire team led by Binna enters the tomb. They travel multiple galleries with walls covered in beautiful artworks dating back to centuries. They of course progress with great care and take tons of pictures of everything they can see. After hours of exploration – mice have small legs and can’t travel very fast – they finally arrive at the main room of the tomb. On shelves they see small lined up statues which should be brought back to the surface for everyone to enjoy.
In front of this incredible spectacle, Binna can’t resist the urge to keep track of the order of the statues so they can reconstruct the way they are arranged in the museum. She also recalls what the curse said above the entrance and finally understands what it was all about: When exiting the tomb, everyone carrying statues will be inevitably cursed. In addition, for a specific mouse, the curse effect will be proportional to the weight of the heaviest statue they are carrying. The -th statue in the line will have weight . That is, if mouse carries some statues and the heaviest statue is statue with weight , then the curse mouse will suffer will be of importance .
When entering the tomb, the team brought many bags with them, each bag can carry at most statues. Due to the size of the bags relative to the size of a mouse, a mouse can only carry at most bag out of the tomb.
Binna wishes to minimize the sum of the curses the team will have to endure once they leave.
To help them keep track of the order of the many statues, the mice have decided that each bag containing statues will contain statues with incrementing positions. That is, the -th bag containing with statues, will contain the statues at the positions .
The team can use as many bags as they want and there are more than enough mice to carry all the filled bags.
Can you help Binna minimize the sum of the maximum weight of the statues present in each bag?
All subtasks have the same input and output format.
The first line contains the number of test cases . The test cases follow in the following format:
For the -th test case, output a line “Case #t:”, followed by the number , the minimum possible sum of the maximum weight of the statues in each bag.
When inspecting the statues more closely, Binna realizes that the statues weights are monotonic. That is, the statues are sorted from lightest to heaviest or heaviest to lightest.
Input:
2 5 2 7 8 9 10 11 3 3 9 5 2
Output:
Case #0: 27 Case #1: 9
Comment:
To submit for this subtask, please log in.
Binna passed by during her afternoon walk and only brought her collection of handbags which can fit 2 statues (you know about the size restrictions on the airplane flights…)
Input:
1 5 2 8 7 10 11 5
Output:
Case #0: 24
Comment:
To submit for this subtask, please log in.
Binna wasn’t expecting to find so many statues and only brought small bags in the tomb.
Input:
2 5 2 8 7 10 11 5 5 3 1 9 5 4 1
Output:
Case #0: 24 Case #1: 11
Comment:
To submit for this subtask, please log in.
The team has never seen as many historical artifacts in one room and have come prepared with large bags.
Input:
2 5 2 8 7 10 11 5 5 3 1 9 5 4 1
Output:
Case #0: 24 Case #1: 11
Comment:
To submit for this subtask, please log in.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Mouse Stofl and Binna are doing multiple cave expeditions in the lands of Uzbekistan, where they try to find crystals and treasures. They already investigated a lot of caves, among which are the famous Boybuloq caverns and the huge Deep Star cave system. In their 33rd expedition, they found something truly terrifying.
At the very bottom of the cave system, they found ruins of an ancient civilization of the “Dark Practitioners”, which was a terrifying cult of moles known for the black magic. In fact, this ruin contains a library full of evil magic that has been lost for centuries. Stofl and Binna need to cover up this ruin as fast as possible such that this dark knowledge doesn’t fall into evil hands.
The cave system is made up of chambers labeled from to . The chambers are all connected to each other through channels. The chamber contains the ruins and is at the very bottom of the cave system. Non ruin chambers with only one channel are cave entrances on the surface, which have different sizes . All other chambers are intermediary and lead down towards the ruins. In order to cover up the ruins, Stofl and Binna have to fill the entire cave system with sand from the nearby Kyzylkum Desert. The red sand of the desert is holy and blocks the dark magic from spreading. They will pour sand into one of the entrances filling up one chamber at a time. The sand will fall down towards the ruins until it reaches them or the next chamber in the direction of the ruins is already filled.
Although both Stofl and Binna want to save the world, they also want to be better than the other one in saving the world. That’s why they take alternating turns pouring sand, starting with Stofl. In one turn, they choose a cave entrance and pour sand into it, filling one chamber or the entrance. If the chamber they fill is the entrance itself, they get points for doing so. They cannot choose an entrance which is already filled and play until there are no unfilled chambers. The mouse with more points in the end is deemed “Hero of the world”.
Given the map of the caves, you will need to determine who will get more points by filling up entrances.
Every entrance leads directly to the ruins, with no chambers in between.
An example of a valid structure would look like this:
The first line contains the number of test cases . For each test case, you will get following lines:
For each test case, output a single line Case #i: P where where is the points Stofl gets and the points Binna gets, assuming they fill up the cave system optimally.
Input:
2 4 0 3 2 5 2 0 0 1 3 0 5 0 1 1 1 1 3 0 0 1 0 4 2 0
Output:
Case #0: -4 Case #1: 0
To submit for this subtask, please log in.
The channels have been dug in a very specific way. There is a central chamber line, and each chamber on that line has zero or more channels directly leading to a cave entrance. They probably used it as a logistics cave.
An example of a valid structure would look like this, where the yellow line indicates central chamber line.
Same as in subtask 1.
Input:
2 3 0 0 3 1 2 1 0 9 0 0 0 4 3 2 5 7 2 4 1 2 8 1 5 3 0 1 0 6 2 7 2 1 2
Output:
Case #0: 3 Case #1: -1
To submit for this subtask, please log in.
Stofl and Binna noticed something interesting: The intermediary chambers have channels only directly to the ruins or entrances. They were likely used as guard post, providing a direct path to the city, but blocking off unwanted visitors from the surface. In addition, a direct path between an entrance at the surface and the ruins never exists.
An example of a valid structure would look like this:
Input:
2 4 0 0 2 9 1 0 1 2 3 1 10 0 0 0 0 4 2 2 6 2 9 0 3 3 9 0 1 8 3 1 4 5 1 2 0 6 2 3 7
Output:
Case #0: 7 Case #1: -5
Binna and Stofl are now interested in general cave systems. For now, they are only concerned in systems where many chambers have collapsed under the rocks. So, not many chambers are accessible anymore.
Same as previous subtasks
Stofl and Binna have big ambitions and want to also solve large general cave systems. Luckily, for now, the entrances look exactly the same, thus covering them up gives the same amount of points. They feel otherworldly…
Same as previous subtasks
The evil aura surrounding the ruins created a very spooky and huge cave system. This feels like the work of a divine being, which was able to hold this huge alien cave system together after all the years.
This is the final test, who is the true hero of the world?
Same as previous subtasks
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
The homework part of the second round (2H) consists of 4 tasks, each of which is worth 25 points. You can gain a maximum of 100 points counting towards your score of the regular round.
2H GraderThis helps you get familiar with our grading system which we will use in all our events after the second round, including workshops, camp, finals, and team selection.
You can submit in C++ (recommended), Java or Python.
C++: | If you don’t have a setup already, we recommend installing VSCode. |
---|---|
Java: | Read Java on the SOI Grader. |
Python: | Read Python on the SOI Grader. |
For 2H you can discuss solutions with friends or publicly on Discord, as long as you don’t share source code. We are also happy to help you! If you need help with the grading system or have questions regarding the theory or tasks, don’t hesitate to ask here or in Discord.
Don’t hesitate to ask us any question about this task, programming or the website via email (info@soi.ch).
Rank | Username | Total (600) | regista… (100) registanpattern | timurid… (100) timuridriders | mouseda… (100) mousedances | fire (100) | roborbuy (100) | bukhara (100) |
---|---|---|---|---|---|---|---|---|
loading ... |
Rank | Username | Total (700) | mouseda… (100) mousedances | fire (100) | roborbuy (100) | bukhara (100) | tombexp… (100) tombexploration | evilruins (100) | 2h (100) |
---|---|---|---|---|---|---|---|---|---|
loading ... |
In the first testcase, the first rider will start at village 1, then go to village 0. The next rider starts at village 2, but the next village, 0, is already occupied, so they stay at village 2.
In the second testcase, the first rider will start at village 2, then go to village 1, then go to village 0.