This contest is over.
Task | Total | Subtask 1 | Subtask 2 | Subtask 3 | Subtask 4 | Subtask 5 |
---|---|---|---|---|---|---|
mergeball | ‒/100 | ‒/20 | ‒/20 | ‒/20 | ‒/20 | ‒/20 |
ceremony | ‒/100 | ‒/10 | ‒/20 | ‒/20 | ‒/10 | ‒/40 |
touristtrap | ‒/100 | ‒/20 | ‒/20 | ‒/30 | ‒/30 | |
pipeline | ‒/100 | ‒/15 | ‒/15 | ‒/10 | ‒/60 | |
storytelling | ‒/100 | ‒/20 | ‒/20 | ‒/15 | ‒/15 | ‒/30 |
tankgolf | ‒/100 | ‒/100 |
Mouse Stofl has a new favorite game: mergeball. In this game there are balls of different sizes on a horizontal rod. As soon as two balls of the same size touch they merge and form a new ball with double the size. If there are multiple possibilities Stofl can decide which balls he wants to merge first as long as there are no other balls in between.
Mous Stofl realizes after some experimentation that it might not always be possible to reach all sizes depending on the starting configuration. As there are very many starting configurations Stofl is not able to test them all by himself. You have to write a program for Mouse Stofl to help him in his quest.
Very often there are two balls of the same size on the rod. Your first program should help Stofl figure out how large the balls get after he merged them.
The first line contains the number of configurations . configurations follow, each consisting of two lines. The first line contains the number of balls , the second line consists of numbers describing the size of the -th ball.
For the -th configuration output “Case #t: k”, where is the size of the resulting ball.
Input:
2 2 5 5 2 7 7
Output:
Case #0: 10 Case #1: 14
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.
For the next games Mouse Stofl only wants to know whether he is able to merge all the balls. First he only considers games where all the balls have the same initial size.
The input format is the same as in subtask 1.
Output the -th configuration as “Case #t: s”, where is either “Single” if all balls merge to one ball, or “Multiple” if there are multiple balls left.
Input:
2 5 3 3 3 3 3 4 7 7 7 7
Output:
Case #0: Multiple Case #1: Single
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.
This subtask is the same as subtask 2 but at the start not all of the balls have to be the same size.
The input format is the same as in subtask 1.
The output format is the same as in subtask 2.
Input:
2 5 3 3 6 6 6 4 7 7 11 11
Output:
Case #0: Single Case #1: Multiple
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.
Stofl already knows the game quite well and wants to build one for himself. At the start he only has balls of one size.
Stofl wants to know in advance which sizes can be reached in his game. To prevent the players from being scared by large balls it is not allowed for balls to be larger than .
Write a program which calculates all possible sizes of balls which can be reached. Print them in sorted order.
The first line contains the number of test cases . test cases follow, each consisting of two lines. The first line contains the number of different sizes of balls and the maximal size which balls may reach. The second line contains numbers , the sizes of the balls which Mouse Stofl owns.
For the -th test case print “Case #t: K ” where is the number of sizes which can be formed, followed by this numbers in increasing order.
Input:
2 1 20 5 1 50 7
Output:
Case #0: 3 5 10 20 Case #1: 3 7 14 28
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 now has more sizes of balls and can therefore build even more complex games.
The input format is the same as in subtask 4.
The output format is the same as in subtask 4.
Input:
2 2 30 5 10 4 50 3 6 7 123
Output:
Case #0: 3 5 10 20 Case #1: 8 3 6 7 12 14 24 28 48
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).
This year, the Mouse Olympiad in Informatics takes place, just as its human counterpart, in Baku, Azerbaijan. The organizers have asked Mouse Stofl to help them prepare the opening ceremony of the competition.
In particular, he’s been designated to organize the big fireworks display that is meant to impress the delegations from all around the world. Stofl is an expert in fireworks, so he’s sure to put on a great show, but there is one little problem: he has to make sure everyone can find a good spot to watch the fireworks.
His idea is the following: there are a lot of new buildings and skyscrapers in Baku, and he would like to launch the fireworks from the top of one of these buildings, and have the participants watch the show from another rooftop. Of course, since there are so many delegations, not everybody is going to fit on a single rooftop, and Stofl wants to find as many suitable rooftops as possible to host as many participants as possible in ideal conditions.
Although there are a lot of buildings to choose from, they aren’t all ideal: the problem is that all these buildings have different heights, and Stofl is not sure whether the fireworks will be visible from every rooftop in the city, since some other buildings may block the view. As a rule of thumb, he’s decided to use the following criterion to determine if the view is ideal: a rooftop offers a good view of the fireworks display if and only if all the buildings standing between the rooftop and the building from which the fireworks are launched are strictly smaller than the rooftop’s building. No participant is allowed to watch from the rooftop where the organizers fire the rockets, for obvious security and liability reasons.
For the sake of simplicity, we will think of the skyscrapers as all standing in a row. There are skyscrapers. The height of the -th skyscraper is . You can ideally see the fireworks launched from the -th skyscraper from the -th skyscraper if and only if and are different and there is no for which both and are true.
Please note that for subtasks 2, 3 and 5, it may take the server quite a long time to grade your solution. Please be patient.
Mouse Stofl would like to know if his simple idea works. He wants to launch the fireworks from the westmost building and install participants on other rooftops rented by the organization from which they can get an ideal view. However, he’s not sure that there are enough buildings offering such a view. Help him figure out how many exactly.
The first line contains the number of test cases . test cases follow, each consisting of two lines. The first line contains the number of skyscrapers and , the index of the skyscraper from which the fireworks are launched (always 0 in this subtask). The second line contains numbers , each representing the height of the -th skyscraper.
For the -th test case, print out a single line “Case #i: M”, where denotes the total number of skyscrapers offering an ideal view of the fireworks display.
Input:
1 6 0 3 2 4 4 6 5
Output:
Case #0: 3
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.
Unfortunately, using your results from Subtask 1, Mouse Stofl determined that there are not enough skyscrapers with an ideal view of the fireworks. Luckily, he contacted owners of other buildings and a lot of them agreed to lend their rooftops for the night. Can you help Stofl again, this time taking into account the many new buildings?
Same as in Subtask 1.
Same as in Subtask 1.
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.
Unfortunately, Mouse Stofl got into trouble with the authorities: they won’t let him launch the fireworks from the skyscraper he originally intended to use. However, they assigned him a new building from which he’s allowed to launch the fireworks. Can you help him calculate how many skyscrapers offer an ideal view now?
Same as in Subtask 1 and 2, but is not always anymore.
Same as in Subtask 1 and 2.
Input:
1 9 4 5 3 2 4 3 2 3 3 1
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.
Mouse Stofl has resolved all the problems he had with the administration and they will now let them use any building to launch his fireworks. That gives Stofl a good opportunity to save a bit on his expenses, by choosing the most visible building. He’s also thinking of using only the originally planned buildings, to save a little more. Help him find out how many buildings will be able to see the fireworks display if he chooses optimally from where to launch them.
The first line contains the number of test cases . test cases follow, each consisting of two lines. The first line contains the number of skyscrapers . The second line contains numbers , each representing the height of the -th skyscraper.
For the -th test case, print out a single line “Case #i: M”, where denotes the maximal total number of skyscrapers offering an ideal view of the fireworks if these are launched from the optimal skyscraper.
Input:
1 9 5 3 2 4 3 2 3 3 1
Output:
Case #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.
Since it turned out the configuration with fewer buildings didn’t offer enough places with ideal visibility for every contestant, Stofl decided to use every building he can, without any regard to his expenses. Can you help him compute how many he may use in the best case, just as in the last subtask, but with many more skyscrapers?
Same as in Subtask 4.
Same as in 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).
Mouse Stofl is currently visiting Baku, the capital city of Azerbaijan. Baku has an old part, which is very beautiful, but also difficult to navigate, because it consists of many narrow streets almost forming a maze. That’s why Stofl chose to go on a guided tour through the city. As the tour progressed however, Stofl got the impression that they will have to go through a store and buy something to continue their trip. Stofl is very frugal and doesn’t want to spend any money if possible, therefore he would prefer to stop the sightseeing early instead.
The question that arises is whether it is possible to get out of the old city without going through a building (which are all stores). Luckily Mouse Stofl has a phone with GPS which shows exactly where he is and has also downloaded a map of the old city of Baku. Can he escape the tourist trap?
The first line of the input contains a single integer () – the number of test cases which follow.
Each test case starts with a line containing four integers , , , and (, , ), the dimensions of the old city of Baku and Stofl’s position.
lines follow, each containing exactly characters. The -th character of the -th line describes whether there is a building or not at position , : # for a building and _ for no building.
For each test case you should output a single line containing the string “Case #t: p” where is the number of the test cases (0-based in increasing order) and is either “POSSIBLE” or “IMPOSSIBLE”: whether or not it is possible to reach any of the border squares without going through a building, i.e. somewhere with or or or .
Input:
2 10 8 2 4 ########__ #____###__ #_#_____## #_#__##_## #__####__# ########_# ##_______# ##_####### 8 7 1 1 ######_# #___##_# #___##__ #___##_# ####___# ######_# ######_#
Output:
Case #0: POSSIBLE Case #1: IMPOSSIBLE
Comment:
Case #0: Stofl starts at the end of the left-hand L-shaped road and can walk to the southern exit.
Case #1: Stofl starts at the piazza in the north west, but it is not connected to the eastern road.
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 creator of the map Stofl is using has updated their map format, because it was getting very large for bigger maps. Now, the roads are stored as a series of rectangles.
The map format is now different. Instead of the lines with characters each, the following format is now used to describe the old city:
A line containing , the number of roads, followed by lines, each describing one road. The -th of these lines contains 4 integers , , , and (, , , ). The position at , is covered by road #i if and . The roads can (but don’t have to) overlap, for example at an intersection.
Same as in subtask 1.
,
Input:
2 10 8 2 4 10 1 1 1 4 2 4 1 1 2 1 3 1 3 2 2 2 3 2 5 1 7 2 1 3 8 4 1 3 2 6 7 1 2 6 1 2 8 0 2 2 8 7 1 1 4 1 1 3 3 4 4 2 1 6 0 1 7 6 2 2 1
Output:
Case #0: POSSIBLE Case #1: IMPOSSIBLE
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.
This is the same as subtask 2, but with bigger inputs.
Same as in subtask 2.
Same as in subtask 1 and 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.
This is the same as subtasks 2 and 3, but with even bigger inputs. Careful: Please read the section grading.
Same as in subtask 2 and 3.
Same as in previous subtasks.
Within reasonable limits, it is in this contest format possible that optimized brute-force solutions may pass. Therefore, we will manually check all submissions and may retroactively give an accepted submission 0 points.
We expect a solution that runs in (possibly with some additional log factors).
Update (2018-09-16): Previously it was written . We expect that the solution runs quasilinear in , the number of streets. It’s not sufficient to be quasilinear in the size of the map or the number of intersections (which could be up to ).
To check that your solution fulfills the requirements, you can check it locally on pre-generated testdata: touristtrap-sub4-large.in and touristtrap-sub4-large.out. Your solution should take between 2min and 10 minutes to compute the correct result.
,
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).
Azerbaijan is the birthplace of the oil industry. To distribute their oil over the world, the Baku—Tbilisi—Ceyhan (BTC) pipeline has recently been opened. Now you are in charge of an even more ambitious project: the Erzurum—Tulcea—Herisau (ETH) pipeline that connects Baku via the BTC and ETH pipeline directly to Switzerland.
The main challenge for such long pipelines is to keep the oil flowing. In order to push the oil forward, you plan to build pump stations. For that you have located possible building spots for those pump stations. The speed of the oil crucially depends on its distance to the nearest pump station. The longest segment without any pump station will be the bottleneck of the whole pipeline. In oil speek, the length of the longest segment without pumps is called the “longest thrust circumvent” (LTC). Your goal is to minimize the LTC.
You know and (the maximal allowed LTC), as well as the possible building locations (, where is the -th possible location for a pump station). Compute the minimal number of pump stations needed for an LTC of at most .
The pipeline starts at and ends at . For technical reasons, locations and must always contain a pump station.
The first line contains the number of test cases . test cases follow, each with and on the first and on the second line. The locations are given in increasing order.
For the -th test case print a line “Case #i:” followed by either:
Input:
4 6 4 2 4 6 7 11 12 3 3 1000 1003 1007 1 3 5 5 2 0 1 2 3 4
Output:
Case #0: 5 2 4 7 11 12 Case #1: Impossible Case #2: 1 5 Case #3: 3 0 2 4
Comment:
Big input:
Input:
2 9000 1 0 1 2 3 ... 8999 9001 1 0 1 2 3 ... 8999 9000
Output:
Case #0: 9000 0 1 2 ... 8999 Case #1: 9001
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.
This time you know and , the number of pumps as well as the possible building locations. Compute the minimal LTC that you can achieve.
The first line contains the number of test cases . test cases follow, each with and on the first and on the second line.
For the -th test case print two lines. The first line should be “Case #i: L”, where is the minimal LTC you can achieve by optimally placing pump stations.
On the second line, if , write exactly numbers , the locations of the pump stations. If , write “Over 9000” instead of the locations of pump stations. Here, denotes the value from the input.
Input:
4 6 5 2 4 6 7 11 12 3 2 1000 1003 1007 1 1 5 5 4 0 1 2 3 4
Output:
Case #0: 4 2 6 7 11 12 Case #1: 7 1000 1007 Case #2: 0 5 Case #3: 2 0 1 2 4
Comment:
Big input:
Input:
2 9000 9000 0 1 2 3 ... 8999 9001 9001 0 1 2 3 ... 8999 9000
Output:
Case #0: 1 0 1 2 ... 8999 Case #1: 1 Over 9000
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 new planned pipeline is so long that there is no way you are able to remember all building locations. Even worse, neither nor the LTC are fixed. You only know an upper bound on the LTC, meaning that you never want to have an LTC higher than .
To deal with those numbers you write a program. You tell the program , the maximal number LTC you will allow. Then, the program reads all building locations in increasing order. In the end, it will give you numbers: the -th number (0-based) tells you the minimal number of pumps you need for guaranteeing an LTC of at most .
Before taking on the ETH pipeline, you walk down the smaller BTC. In the BTC, the input is small enough so that your program can store all numbers. However, the last subtask will be exactly the same except that it is about the ETH and there you can no longer do that. To save you some work we recommend you to read the last subtask before solving this one (though you can solve this subtask by any means necessary).
The first line contains the number of test cases . test cases follow, each with and on the first and on the second line.
For the -th test case print a single line “Case #i:”, followed by numbers “”, where is the minimal number of pump stations you need for achieving an LTC of at most . If it is not possible, print instead.
Input:
4 6 10 2 4 6 7 11 12 3 7 1000 1003 1007 1 1 5 5 4 0 1 2 3 4
Output:
Case #0: -1 -1 -1 5 3 3 3 3 3 2 Case #1: -1 -1 -1 3 3 3 2 Case #2: 1 Case #3: 5 3 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.
Now it’s time for the real thing: the ETH. As we can not verify the memory consumption of your program, this is a theoretical subtask. Describe an algorithm that can solve subtask 3 and analyze its running time and memory usage.
You should optimize for memory usage first and running time second. See grading for more details.
Hand in a document (preferably PDF) that describes
The memory consumption of your data structure should only depend on , not . Aim for memory, but it’s fine if you need slightly more than that.
If everything else is correct, we will give you points based on the table below.
Memory usage | Running time | Max score |
---|---|---|
20 | ||
40 | ||
50 | ||
50 | ||
60 |
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).
Mouse Stofl went to explore Azerbaijan so that he can tell you what to see and do there when you go to compete in IOI 2019. Today he visited the famous fire mountain Yanar Dag – a place where rocks and water spontaneously ignite into flames. In the evening Stofl has arranged an overnight stay at Mouse Yusif’s home. The hospitality of Azerbaijani mice astonished Stofl as Yusif’s whole family has gathered at Yusif’s home to honor Stofl.
For the dinner all mice (including Stofl) sat around a round table. In Azerbaijan it is customary to tell stories before eating dinner. This storytelling has to follow some strict rules (especially in the presence of a dear guest):
The mice are already quite hungry and they want food as soon as possible.
You are given positive integers – the lengths (in seconds) of the stories our mice want to tell tonight. The lengths are given in the order in which the mice sit at the table. Find the optimal schedule for the storytelling.
The first line contains the number of test cases .
test cases follow, each in the following format: The first line of each test case contains one integer : the total number of mice siting at the table. The second line of each test case contains space-separated integers: the numbers .
For each test case, output two (subtasks 1 and 2) or one (subtasks 3 and 4) lines:
If there are multiple optimal solutions, you may output any one of them.
Input:
2 5 1 1 1 1 1 6 2 3 1 2 2 1
Output:
Case #0: 3 0 1 2 0 1 Case #1: 5 0 2 0 1 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.
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 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 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 assume that in subtasks 3 and 4 you were asked to also print the .
Give a proof that your solutions of subtask 3 and 4 are correct and analyze their running time. A correct proof for only one of the two subtasks (3 or 4) is worth at most 15 points.
We recommend the following proof template: (The italic statements should be completed by you.)
The algorithm looks like this and computes that because of this explanation.
Its running time and space usage is because it’s true.
Given an arbitrary input , the output of the algorithm is both:
- an upper bound on the optimal solution: The numbers as produced by the algorithm satisfy the constraints because of your proof thus any optimal solution must use at most seconds.
- a lower bound on the optimal solution: It is impossible that any solution uses less than seconds because of your proof.
Thus the output is optimal.
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).
To solve this task, you should first download the host server for the game, which allows you to test your bot locally.
Check out the Readme to the host server as well, there you find instructions on how to compile the host server. You can find some example bots in the directory bots/ to get you started.
If you encounter any problems while compiling the host server, don’t hesitate to ask questions to pascal@soi.ch.
See TankGolf on the Google Playstore for Android. The task is basically to write a bot for this game.
Two tanks are in a 2d physics simulation (upright), where a tank can shoot a bullet with a desired angle and intensity. The bullet causes an explotion wherever it impacts a surface, and the goal is to push or throw the other tank into a hole in the map through the shockwave of the explosion. The player take turns at shooting, and one can only shoot when both tanks have come to a rest after the last explosion (or the bullet shot by the opponent has fallen off the map). When a player falls through the hole, the opponent gets a point and the player respawns.
The task is to write a bot that, given the current positions and orientations of the tanks, determines an angle and intensity to shoot. The shot will be executed with a uniform random distribution within a small range around the desired angle and intensity. The uncertainty radius depends on the square of the intensity, such that long range shots are more risky than short range.
The game server provides a function to look up the impact position of the bullet, and the positions where the tanks come to a rest after the explosion, given a game state and desired trajectory. The bot can call this lookup function as often as you want, but please make sure that the bot doesn’t take longer than a few seconds for every turn (The time required to show the visualization isn’t counted in this). The randomness will only be added when the bot commits to a final shot, and does not affect any lookups.
The description of the map can be found in geometry/maps/map1.json, or you can look at it using the provided visualization. The map used in the contest will be exactly the same.
To respawn, your bot can chose an x-coordinate to spawn at, then the tank will drop down at this x-coordinate from a fixed y-coordinate. Y is fixed to make sure you can’t spawn into the floor or the other player. If you want to spawn right above the hole, you are very welcome to do so. There is also a query method available for respawning, similar to the query method for shots. A tank respawns as soon as they fell off the map. If both tanks fall off the map, both spawn in first, then the bots continue in their alternating order of shooting turns.
There are two types of round, one where the bot can line up a shot, and one where the bot chooses a spawn position.
Your bot will always see itself as player A in the protocol, so player B is always the opponent in the data that you receive.
A game state has two representations, one for transmitting the full state and one for a subset of the full state:
full: | playerA.x playerA.y playerA.angle playerB.x playerB.y playerB.angle last_impact.x last_impact.y scores.playerA scores.playerB |
---|---|
small: | playerA.x playerA.y playerA.angle playerB.x playerB.y playerB.angle |
A position that is not on the map is represented as -1, -1. For example a player position if they fell off the map or last_impact before the first shot are -1, -1.
Every round starts by the server sending the current type of round: ‘startrespawn’ or ‘startshoot’, followed by the full state (Initial spawn counts as respawn)
Server: | startrespawn <full game state> |
---|
(player asks a query…)
Player: | queryrespawn 12.345 where the player asks what would happen if I drop down at this x position |
---|---|
Server: | state <full resulting state at rest> |
(… zero or more queries in total)
Player: | respawn 12.345 respawn at this location |
---|
(turn is over)
Server: | startshoot <full game state> |
---|
(player asks a query..)
Player: | queryrespawn 1.13 0.9 where the player asks what would happen if I shoot with this angle and intensity |
---|---|
Server: | state <full resulting state at rest> |
(.. zero or more queries in total)
Player: | shoot 1.13 0.9 shoot with this angle and intensity |
---|
(turn is over)
Player: | fullqueryshoot <small state> 1.13 0.9 where the player gives a game state and asks what would happen if I shoot with this angle and intensity |
---|---|
Server: | state <full resulting state at rest> |
Player: | fullqueryrespawn <small state> 12.345 where the player gives a game state and asks what would happen if I drop down at this x position |
Server: | state <full resulting state at rest> |
Note that this example only shows the communication for one of the players.
< is server to client and > is client to server < startrespawn -1 -1 0 -1 -1 0 -1 -1 0 0 # We're player one and thus noone is on the map yet. Bullet hasn't impacted yet. Scores are at zero. # read as: tank A: (-1, -1) 0 | tank B: (-1, -1) 0 | impact pos: (-1, -1) | scores: 0 0 > respawn 2 # Spawn at position 2 (other player respawns) < startshoot 2 1 0 6 1 0 -1 -1 0 0 # Other player has spawned at coordinate 6. We shoot first > queryshoot -1.13 0.6 # Simulate shot 1.13 radian to the right < state 2 1 0 -1 -1 0 7.2 1 # Other player would fall in hole, we wouldn't move. We would get a point. # read as: tank A: (2, 1) 0 | tank B: (-1, -1) 0 | impact pos: (7.2, 1) | scores: 1 0 > shoot -1.13 0.6 # Shoot as simulated before. # What the player doesn't know immediately, but what we see in the next server command is, that the shot # didn't work out because of the added randomness (impact was at 7.4, 1). We didn't get a point. (other player shoots) < startrespawn -1 -1 0 4.6 1 0 1.5 1 0 1 # The other player scored during their turn (last impact was at 1.5, 1). We need to select a respawn position. > respawn 6 < startshoot 6 1 0 4.6 1 0 1.5 1 0 1 # We get to shoot immediately after respawning, because the other player was the last one to shoot. ...
You play against the other participants of the SOI. At SOI-Day the programs will compete in a tournament to determine the best bot. You are allowed to submit up to three bots. Your best bot will be used for the ranking. Bundle the files in a zip archive when submitting.
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 (600) | mergeball (100) | ceremony (100) | tourist… (100) touristtrap | pipeline (100) | storyte… (100) storytelling | tankgolf (100) |
---|---|---|---|---|---|---|---|---|
loading ... |