id
stringlengths
11
14
content
stringlengths
424
1.17M
apps_data_3100
You are the boss of ACM (Apples, Cherries, and Mangos), an upstanding company with a single goal of world domination. ACM have provided lots of fruits for the last programming competition for minions in Helsinki. The leftovers should now be shipped to Singapore. There is, however, one constraint: In the case that one ...
apps_data_3101
Once upon a time, high up on Mount Olympus, it came to pass that the gods held a competition to see who among them was the best at sorting lists of integers. Eris, the goddess of discord, finds this terribly boring and plans to add some mischief to the mix to make things more fun. She will sabotage the answers of Zeus ...
apps_data_3102
“A foole and his monie be soone at debate: which after with sorrow repents him too late.” ­–Thomas Tusser. The real estate bubble has popped, and the country has been thrown into a housing market crisis! You, an aspiring developer, sensed opportunity in the midst of chaos, and have decided to come in and snatch some p...
apps_data_3103
Lysias loves his full-rigged ship and takes it out to his island castle as often as possible. On his way back to the castle one day, the engines capable of turning the sails failed. As it is a full-rigged ship, he and his crew are now unable to turn the sails in any direction. But, as luck would have it, there is a so...
apps_data_3104
While browsing a math book, Mirko found a strange equation of the form $A=S$. What makes the equation strange is that $A$ and $S$ are not the same. Mirko realized that the left side of the equation should have addition operations between some pairs of digits in $A$. Write a program that inserts the smallest number of ...
apps_data_3105
You are the boss of Wi Know, an upstanding company in information theory, especially in message encryption. The counter-counter-intelligence branch of your upstanding company managed to intercept a message sent by the counter-intelligence agency of the local Helsinkian government. This message is, of course, of utmost...
apps_data_3106
You have $n$ lights, each with its own button, in a line. Pressing a light’s button will toggle that light’s state; if the light is on, it will turn off, and if the light is off, it will turn on. The lights change at $1$ second timesteps. You can press a button at any time, but it will not take effect until the next ti...
apps_data_3107
We are observing the movement of $N$ trucks on the road. The road can be represented as a number line. The points on the line denoting cities are integers. The cities are denoted with the number of the corresponding point on the line. All trucks are moving with the same speed and no single truck is standing still at a...
apps_data_3108
You are given an array of $N$ integers. Find a consecutive subsequence of numbers of the length at least $K$ that has the maximal possible average. -----Input----- The first line of input contains two integers $N$ ($1 \leq N \leq 3 \cdot 10^5$) and $K$ ($1 \leq K \leq N$). The second line of input contains $N$ integer...
apps_data_3109
At art shows, it is very common to have booths where children can create their very own sand art. This art is typically made by taking a jar or bottle and filling it with layers of different colors of sand. Instead of a bottle, this year a new container is being used for decorating! The container is a glass box! The b...
apps_data_3110
You’re one of the king’s spies sent on a secret mission to retrieve an item of incredible value, an ancient scroll from the throne room. Legend has it, the scroll contains the answer to the $P$ versus $NP$ problem. When you finally reach the throne room, you realize there is a code the guards enter every day while obse...
apps_data_3111
Luka is not paying attention in class again, while the teacher is explaining redox reactions. Instead of paying attention, he is playing with analog dials. An analog dial is a small device which always shows one digit between $0$ and $9$. It also contains a small button which increases the number by $1$ (unless it is ...
apps_data_3112
Your factory has $N$ junctions (numbered from $1$ to $N$) connected by $M$ conveyor belts. Each conveyor belt transports any product automatically from one junction to another junction in exactly one minute. Note that each conveyor belt only works in one direction. There can be more than one conveyor belt connecting tw...
apps_data_3113
Garry is looking at the sky. Such a beautiful day! He notices that the clouds are particularly beautiful today, and wishes to record the current state of the sky. He has no camera, so he begins writing down coordinate points. Fortunately for Garry, the current cloud cover can be represented as the union of non-intersec...
apps_data_3114
In the ACM kingdom, there are $N$ cities connected by $M$ two-way roads. These cities are connected, i.e., one can reach from any city $X$ to any other city $Y$ by going through some of these roads. One day, the government wishes to assign for each road a direction, such that one can still reach from any city to any ot...
apps_data_3115
Your friend is an organizer of the International Chess Playing Championship. He is worried that some of the contestants may be cheating, and he has asked you to help out. The chess players are allowed to report matches to the jury themselves, and this is not checked with the reported opponent. So, it is possible for co...
apps_data_3116
Vera is an astronomer studying locality of nearby star systems. The star systems can be thought of as 3D points in space. Vera would like to place a can around the stars. In other words, she would like to know what is the smallest volume cylinder that encloses the stars. The cylinder can be oriented in any direction. A...
apps_data_3117
Ivana won the bet (Zvonko hadn’t foreseen this and suspects that it is due to outside interference) and now Zvonko is waiting for her at the movies. While he is waiting, he is observing messages on a screen above him. As Ivana is running late, Zvonko has been looking at the screen for a while and noticed that some mes...
apps_data_3118
Alice and Bob love playing Don’tminion, which typically involves a lot of shuffling of decks of different sizes. Because they play so often, they are not only very quick at shuffling, but also very consistent. Each time Alice shuffles her deck, her cards get permuted in the same way, just like Bob always permutes his c...
apps_data_3119
Rhythm gaming seems to be having a bit of a renaissance this October, with both a new “Rock Band” and a “Guitar Hero” game coming out. Bj0rn is preparing to achieve top scores in “Guitar Hero Live”, but he needs your help in figuring out what the maximum score is for all the new songs. Apparently, the new game has some...
apps_data_3120
In programming contest circles, one of the most important roles is that of the Chief Equality Officer (CEO). This person is responsible for making sure that every team has an equal chance of winning the contest. Since last year’s NWERC the current CEO, Gregor, has thought at length about how to make the contest even mo...
apps_data_3121
The other day Unnar was playing the video game Geezer Scripts, Geezer Scripts V to be precise. He opened a door (in the game) and before he knew he was in a large and complicated cave-system, full of enemies who will attack as soon as Unnar gets to close to them. What’s worse is that the game doesn’t remember which ene...
apps_data_3122
Amanda Air has routes between many different airports, and has asked their most important frequent flyers, members of the AA Frequent Flyer program, which routes they most often fly. Based on this survey, Amanda, the CEO and owner, has concluded that Amanda Air will place lounges at some of the airports at which they o...
apps_data_3123
Nested quotations are great not only for writing literature with a complex narrative structure, but also in programming languages. While it may seem necessary to use different quotation marks at different nesting levels for clarity, there is an alternative. We can display various nesting levels using $k$-quotations, wh...
apps_data_3124
Even though she saw Zvonko steal Mirko’s microprocessor in the second task, Mirko’s sister Ivana did not tell Mirko because she likes Zvonko. She suggested to him that they go see a movie together so that she would “forget” about the incident. Zvonko does not care much for girls because they take away precious time he...
apps_data_3125
Apostrophes and double quotes tend to get badly encoded by systems, causing them to print back things like ' or \". As a QA tester, Nova has seen lots of these issues. Today, she overheard that the Tweeper messaging app may have an issue with these symbols as well, and may encode them in strange ways. This was int...
apps_data_3126
As you may know, the frogs are the biggest show-offs of the entire animal kingdom. Some weeks ago, they greatly impressed the other animals by forming a large tower. However, the frog king wants to surpass this performance at the next Benelux Amphibian Pillaring Ceremony (BAPC). He wants the frogs to perform a difficul...
apps_data_3127
Having recently been hired by Netwerc Industries as a network engineer, your first task is to assess their large and dated office network. After mapping out the entire network, which consists of network switches and cables between them, you get a hunch that, not only are some of the switches redundant, some of them are...
apps_data_3128
A long time ago in a galaxy far, far away$\ldots $ there was a cinematic universe with countless sequels, prequels, and everything in-between. You have always been confused of the ordering of the Star Wars movies. First they created the plot order movies $4$, $5$ and $6$. Then movie $1$, $2$ and $3$. Now they are creat...
apps_data_3129
Peter has lined up hay bales. Some hay bales contain parasites and he wants to move the infected hay bales to the back of the sequence, to minimize the chance that the parasites spread. To sort the haybales, he repeatedly takes out any three consecutive hay bales and puts them back in sorted order. Your task is to calc...
apps_data_3130
Sherlock Holmes is a renowned detective. His Scotland Yard colleagues often provide him with a set of evidence and ask for his help in solving the mysteries. After many years of practice, Holmes has gained an enormous amount of experience and already knows causes for many common events, which, combined with his extraor...
apps_data_3131
—“I’m stopping by Žnidaršić’s house, you play the piano, Perica.” —“Ok, dad, I will!” And so, Perica began playing the piano. His piano consists of $N$ keys. Each key has a value written on it, $a_ i$. When Perica plays the piano, he presses exactly $K$ different keys at the same time. The piano is a bit strange bec...
apps_data_3132
Archeologists recently found the remains of Greco-Roman architecture. The location can be modeled as a grid of $R \cdot C$ square cells. For each of the cells, archeologists have determined if some building was there or if the cell has always been empty. After examining the artifacts in detail, they concluded that the...
apps_data_3133
Alice and Bob are travelling in Italy. They are travelling by car and unfortunately they took a wrong turn. Now they are stuck in the city centre of Pisa. (You may know that you need an allowance to drive in the city centre, so they are at risk of getting a fine.) As they were not fully prepared for this, they have a m...
apps_data_3134
Consider an $n \times m$ matrix of ones and zeros. For example, this $4 \times 4$:$\begin{matrix} 1 & 1 & 1 & 1 \\ 0 & 1 & 1 & 1 \\ 0 & 1 & 1 & 1 \\ 0 & 1 & 1 & 0 \end{matrix}$ We can compute even parity for each row, and each column. In this case, the row parities are $[0, 1, 1, 0]$ and the column parities are $[1, 0...
apps_data_3135
“Increase my killing power, eh?” – Homer Simpson You are probably familiar with the binary representation of integers, i.e. writing a nonnegative integer $n$ as $\sum _{i=0}^k a_ i \cdot 2^i$, where each $a_ i$ is either $0$ or $1$. In this problem, we consider a so called signed binary representation, in which we st...
apps_data_3136
Greg Brandon Sr. is working at a shipping company in Redmond that specializes in shipping Chromium. Redmond contains $n$ intersections and $m$ two-way roads that directly connect two intersections (Redmond can be modelled as a graph with $n$ vertices and $m$ edges). It is always possible to travel from any intersection...
apps_data_3137
Luka is bored in chemistry class yet again. This time, he’s playing with intelligent bacteria. He has arranged his $K$ bacteria on a rectangular board divided in $N$ rows, labelled with numbers from $1$ to $N$ starting from the top, and $M$ columns, labelled with numbers from $1$ to $M$ starting from the left. Each ba...
apps_data_3138
Sarah and Patricia are young, very gifted sisters. Ever since they learned arithmetic in preschool, they have been bothering their mother Marguerite day and night to practice their calculations. Marguerite bought the two girls an arithmetic practice book, which has $n$ pages and a positive integer on each page. Those i...
apps_data_3139
It’s exam time in Mirko’s village. Everyone wants to pass the exam with as little effort as possible, which is not easy. Mirko realized that it would be best for him to find someone who knows more than him and learn from them. Everyone followed and now everyone is looking for someone to learn from. We can model how wel...
apps_data_3140
In a fishing contest, the participants fish in a lake, represented as a 2D grid of dimension $r \times c$. Each integer point in the grid contains fish. At point $(x, y)$, fish first appear at second $t_{x, y}$ and disappear just before time $t_{x, y} + k$ seconds. Outside of this time, no fish can be caught at this ...
apps_data_3141
An artist who wanted to create an installation where his works appeared to be floating in midair has cast a large cube of clear acrylic to serve as a base. Unfortunately, during the casting, some small flecks of dirt got into the mix, and now appear as a cluster of pinpoint flaws in the otherwise clear cube. He wants ...
apps_data_3142
Božo is a strange little boy. Every day he tires his friends with strange questions. Today’s question is: how many integers in the interval $[A, B]$ are there such that the sum of their digits is $S$, and which is the smallest such number? Write a program that answers Božo’s question so that he can get some sleep. --...
apps_data_3143
It is the first day of school at Liking University, or “Lku” for short. Lku administration is very strict with attendance, especially on the first day. In order to verify everyone’s attendance, the Lku’s principal has made an attendance list. He then asked to all students to stand in line to his office in order to mark...
apps_data_3144
Donald is playing a game of cards against his cousin Gladstone. Each round proceeds as follows: - Donald chooses an (integer) amount of coins and both of the cousins puts that many coins in the pot. - The cards are dealt. - The game is played. - The player who won gets all the coins in the pot. This continues unti...
apps_data_3145
Zvonko is playing with digits again, even though his mother has warned him that he is doing too much math and should go outside to play with his friends. In his latest game, Zvonko looks for multiples of an integer $X$, composed only of certain digits. A multiple of $X$ is any number divisible by $X$. In order to rui...
apps_data_3146
Many pharmacies in the United States fill prescriptions strictly on a first-come, first-served basis, even preferring prescriptions submitted electronically from a remote site to prescriptions dropped off by waiting customers in the store. This frequently leads to situations where customers have to wait for prescriptio...
apps_data_3147
While debugging a program Mirko noticed that a bug in the program may be linked with the existence of so called square killers in the program memory. The program memory is a matrix composed of $R$ rows and $C$ columns consisting only of zeroes and ones. A square killer is a square submatrix in memory, consisting of mor...
apps_data_3148
Lifeguards have a very important job. They prevent people from drowning and allow millions of people every year to experience the joys of water. You are one of these lifeguards, and you take your job very seriously. If regulations were up to you, everyone would have to wear life vests when in the water, which is why yo...
apps_data_3149
It is the time for the Holidays, which means it’s time for the annual Holiday Cookie Throwing contest where cookies are thrown against a wall. Cookies are really simple polygons that rotate clockwise while in flight. Due to many years of advanced research and precise throwing equipment, these cookies can fly under ide...
apps_data_3150
Near a military base there is a system of trenches, modeled as line segments on a plane. During nighttime, when most soldiers are fast asleep, three guards stand watch of the trenches. Two guards can see each other if there is a trench (or a row of trenches) along the entire straight line segment between them and there...
apps_data_3151
You are an architect and you have just been appointed to build a new swimming hall. The organisation behind these plans has acquired funding for a swimming pool and surrounding building as large as they want, but unfortunately they could not find anyone willing to pay for the floor surrounding the pool. They decided to...
apps_data_3152
Mirko got an array of integers for his birthday from his grandmother Norma. As any other kid, he was hoping for some money, but got an array. Luckily, in his town there is a pawn shop that buys up arrays. The cost of an array of integers is $\min \cdot \max \cdot L$ kunas, where $\min $ is the minimal integer in the ar...
apps_data_3153
After their pool burst, Mirko and Slavko started collecting cards. In their neighbourhood, card collection is taken seriously and there are strict rules for the purchase and trading of cards. Purchasing cards is always done by two children together. Each of them gives half the required funds and two cards are bought. ...
apps_data_3154
It is chaos playtime at kindergarten again, and teacher Tom is having some difficulties. You see, kids often have disagreements about who should play with which toy. Whenever a kid perceives any form of injustice in the allocation of toys to kids, they start crying uncontrollably. The kids are clearly poor decision mak...
apps_data_3155
The robot revolution is finally here, albeit not quite in the highly explosive way envisioned in various science fiction books and movies. It seems that, perhaps due to a small typo in the AI source code, the robots are not taking our lives but instead taking our livelihoods. One early job market fatality in this revol...
apps_data_3156
Your little sister has been a big help today: she went into town to do all the groceries! During this grand voyage, she was accompanied by her fluffy friend, Mr. Fluffynose the Stuffed Animal. However, after her return, it seems that she has left him somewhere along the route! This is devastating news for your little s...
apps_data_3157
Little Mirko is studying the hash function which associates numerical values to words. The function is defined recursively in the following way: - $f( \text {empty word} ) = 0$ - $f( \text {word} + \text {letter} ) = ( ( f( \text {word} ) \cdot 33 ) \oplus \mathrm{ord}( \text {letter} ) ) \mathbin {\% } \mathrm{MOD}$...
apps_data_3158
With the advent of touch-screen based interfaces, software designers have had to reinvent computer control for finger-based gestures. The most basic task in interpreting a gesture is classifying the touches into one of several possible gestures. This can be difficult because the touches are really blobs of pixels on th...
apps_data_3159
Web pages are littered with ads (advertisements) these days. You wrote a simple program to detect images which are ads and remove them. Characters that are any of the following are allowed in images: - alphanumeric characters - question mark ‘?’ - exclamation mark ‘!’ - comma ‘,’ - full stop ‘.’ - whitespace ‘ ’...
apps_data_3160
After passing the final round of the Hunter Exam, Gon is now a Hunter! But before continuing his exciting journey, Gon decides to visit his home in ‘While Island’. Aunt Mito is happy that Gon has become a Hunter and has visited home. But at the same time, she feels worried about Gon — the life of a Hunter is challengi...
apps_data_3161
Josip is a strange painter. He wants to paint a picture consisting of $N \times N$ pixels, where $N$ is a power of two ($1, 2, 4, 8, 16$ etc.). Each pixel will be either black or white. Josip already has an idea of how each pixel will be coloured. This would be no problem if Josip’s painting process wasn’t strange. He...
apps_data_3162
An LCD panel is composed of a grid of pixels, spaced $1$ alu (“arbitrary length unit”) apart both horizontally and vertically. Wires run along each row and each column, intersecting at the pixels. Wires are numbered beginning with $1$ and proceeding up to a panel-dependent maximum. The vertical wire numbered $1$ lies a...
apps_data_3163
Librarian Jurica has $N$ shelves in his library, and each shelf can contain $M$ books. Jurica is a good librarian so he decided to make an inventory in the library and, if it’s necessary, return the books that aren’t in their place to their right place. He moves the books in the following way: - moving the books one p...
apps_data_3164
Zapray recently did not have much time to finish his homework due to his addiction to Pokemon. What is even worse, this week’s algorithm class has assigned a very challenging homework problem: “Given an array of integers, find the longest consecutive sub-array so that each element in the sub-array appears exactly twice...
apps_data_3165
Mirko is a huge fan of chess and programming, but typical chess soon became boring for him, so he started having fun with rook pieces. He found a chessboard with $N$ rows and $N$ columns and placed $K$ rooks on it. Mirko’s game is made of the following rules: - Each rook’s power is determined by an integer. - A rook...
apps_data_3166
The Swedes wanted to arrange a ping pong tournament among the $n$ high school students in the nation. Since Sweden is the fairest country on earth, they wanted to ensure that the ranking of all the players is perfectly fair. Therfore, they decided that every high school student in the nation should play against every o...
apps_data_3167
Mirko is trying to debug a piece of his code. First he creates an array of $N$ integers and fills it with zeros. Then he repeatedly calls the following C++ procedure: void something( int jump ) { int i = 0; while( i < N ) { seq[i] = seq[i] + 1; i = i + jump; } } As you can see, this procedure increases by one a...
apps_data_3168
A binary search tree is a tree in which every node has at most two children nodes (a left and a right child). Each node has an integer written inside it. If the number $X$ is written inside a node, then the numbers in its left subtree are less than $X$ and the numbers in its right subtree are greater than X. You will b...
apps_data_3169
You have most definitely heard the legend of King Arthur and the Knights of the Round Table. Almost all versions of this story proudly point out that the roundness of the Round Table is closely related to Arthur’s belief of equality among the Knights. That is a lie! In fact, Arthur’s choice of table is conditioned by h...
apps_data_3170
From her friends, Theta learned a $2$-player card game called Trash. Trash is played with a standard $52$-card deck consisting of Ace, $2$ to $10$, Jack, Queen, and King in each of the $4$ suits. Each player is dealt $10$ cards face down that are arranged in $2$ rows for each player as shown in the figure. The first ro...
apps_data_3171
Excitement is rapidly increasing in anticipation of the concluding debate at the 0x7E4 Undemocratic Inclinational Unconvention, where the party’s candidate for the office of Student Assistant to the Old Chemistry Building Assistant Printer Service Technician’s Assistant will be elected. To secure a revered lifetime app...
apps_data_3172
John, a student who is taking the game development course, recently developed a mobile game called Fruit Slicer for his coursework. In the game the player slices fruits that are throw into the air by swiping the touch screen. However the game is quite simple because John was not able to write code for the geometry requ...
apps_data_3173
In the second round of the Hunter Exam, the candidates are faced with an even more challenging problem, requiring both agility and mathematical skills. After entering the Examination Hall for the second round, candidates are faced with a huge vertical grid containing empty spaces, obstacles and conveyor belts. The gri...
apps_data_3174
A distant country has $N$ cities in it. The elections were just held in this country, so the new prime minister was elected. Currently, there is not a single road in this country, so the prime minister decided to modernize the country by connecting some cities with two-way highways and form counties. Two cities will be...
apps_data_3175
David and Martin retired from their jobs and became shepherds. After each winter they need to rebuild the sheep pen. Each year they have a different collection of straight fence segments of various lengths. Naturally, they want to build a sheep pen that covers the largest area. They always spend a lot of time choosing,...
apps_data_3176
Barica is an unusual frog. She lives in a pond where $N$ plants float on the surface of the water. The plants are numbered $1$ through $N$. When viewing from above, the location of each plant is given by a pair of coordinates. What makes Barica unusual is her fear of jumping diagonally and in the negative direction. Mo...
apps_data_3177
“Arrange” is a planetary popular Flash game. In “Arrange” the player is given a permutation of numbers $1$ to $N$ and a list of allowed swaps. He then has to perform a sequence of swaps that transforms the initial permutation back to the ordered sequence $1,2,3,4,5, \ldots , N$. In order to break the high score list, ...
apps_data_3178
Peter’s favorite season is winter. Caught up in the festivities, Peter would like to decorate his city. The city has many areas for things like ice skating, skiing, and snowball fights. There are roads connecting some pairs of areas. Peter would like to put a special decoration along each of these roads. There are thr...
apps_data_3179
Canyons are deep ravines between escarpments or cliffs. They exist on more than just Earth. For example, Valles Marineris on Mars is a vast canyon system running along the Martian equator and is roughly the size of the United States. Working for a prestigious mapping company, you’ve been tasked with making maps for su...
apps_data_3180
Mirko has just installed a brand new drawing program. The program supports $K$ different colours, denoted by integers from 1 to $K$. All drawing is performed on a canvas with dimensions $N\times N$. In the beginning, all cells are white (denoted by 1). The upper left cell of the canvas has coordinates $(0, 0)$. The fi...
apps_data_3181
All of you are probably very familiar with the problem of finding the longest monotone subsequence. You probably think you know all about it. In order to convince us, solve the problem “opposite” to finding the longest monotone subsequence. For given $N$ and $K$, find a sequence that consists of numbers from $1$ to $N...
apps_data_3182
$N$ points are placed in the coordinate plane. Write a program which calculates in how many ways a right triangle can be formed by three of the given points. A right triangle is one in which one of the angles is $90$ degrees. -----Input----- The first line of input contains an integer $N$ ($3 \le N \le 1500$), the nu...
apps_data_3183
-----Input----- The first line of input contains a line contains a line with four non-negative integers, $2 \le n \le 250$, $0 \le m \le 5000$, $0 \le s \le n-1$ and $0 \le t \le n-1$, separated by single spaces, where $n$ is the numbers of nodes in the graph, $m$ is the number of edges, $s$ is the source and $t$ is th...
apps_data_3184
The International Corporation for Protection and Control (ICPC) develops efficient technology for, well, protection and control. Naturally, they are keen to have their own headquarters protected and controlled. Viewed from above, the headquarters building has the shape of a convex polygon. There are several suitable pl...
apps_data_3185
A factorial $n!$ of a positive integer $n$ is defined as the product of all positive integers smaller than or equal to $n$. For example,\[ 21! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot 21 = 51090942171709440000. \] It is straightforward to calculate the factorial of a small integer, and you have probably done it many tim...
apps_data_3186
You have $N$ objects, each with $M$ copies. How many ways are there to take exactly $K$ of them? -----Input----- The first line of input contains three integers, $N$, $M$ and $K$ respectively, subjected to $1 \leq N, M, K \leq 10^5$. -----Output----- Output the number of ways. As the number of ways could be large, ou...
apps_data_3187
The citizens of Fictitia have had enough! The city keeps getting bigger and bigger, and all the more boring. Fictitia consists of horizontal and vertical streets only. The distance between each pair of neighboring parallel streets is always the same; we take this as the unit distance. Surely some variation could not hu...
apps_data_3188
Fourth Great and Bountiful Human Empire is developing a transconduit tunnel network connecting all it’s planets. The Empire consists of $N$ planets, represented as points in the 3D space. The cost of forming a transconduit tunnel between planets $A$ and $B$ is:\[ \operatorname {TunnelCost}(A,B) = \min \{ |x_ A - x_ B |...
apps_data_3189
Your competitors are in possession of a mysterious apparatus which gives them an advantage over you. The apparatus has $n$ on/off switches and $n$ lights. We believe that each of the switches is connected to exactly one of the lights, and vice versa, but we don’t know which switch is connected to which light. Your spy...
apps_data_3190
Young Mirko has been buying voodoo dolls lately. Considering that he is very interested in the cheapest purchase possible, he has been tracking the prices of voodoo dolls each day. His price list consists of doll prices in the last $N$ days, where doll price $a_ i$ represents the price of a doll $i$ days ago. Mirko th...
apps_data_3191
Your fancy debugger will not help you in this matter. There are many ways in which code can produce different behavior between debug and release builds, and when this happens, one may have to resort to more primitive forms of debugging. So you and your printf are now on your own in the search for a line of code that ...
apps_data_3192
You just graduated from programming school and nailed a Python programming job. The first day at work you realize that you have inherited a mess. The spaghetti design pattern was chosen by the previous maintainer, who recently fled the country. You try to make sense of the code, but immediately discover that different ...
apps_data_3193
A student called Slon is very mischievous in school. He is always bored in class and he is always making a mess. The teacher wanted to calm him down and “tame” him, so he has given him a difficult mathematical problem. The teacher gives Slon an arithmetic expression $A$, the integer $P$ and $M$. Slon has to answer the...
apps_data_3194
Images by John Fowler, Carol Highsmith, and Richard Woodland You have decided to spend a day of your trip to Rapid City taking photographs of the South Dakota Badlands, which are renowned for their spectacular and unusual land formations. You are an amateur photographer, yet very particular about lighting conditions. ...
apps_data_3195
Sarah is cycling to work. On her way there, she encounters the same traffic light every day. Before she reaches the lights, she alternates between using social media on her mobile device and glancing at the traffic lights, observing if they are green, yellow or red at that time. From experience, she knows that the ligh...
apps_data_3196
A bicycle race is being organized in a land far, far away. There are $N$ towns in the land, numbered $1$ through $N$. There are also $M$ one-way roads between the towns. The race will start in town $1$ and end in town $2$. How many different ways can the route be set? Two routes are considered different if they do not...
apps_data_3197
Organising a group trip for the elderly can be a daunting task... Not least because of the fussy participants, each of whom will only make the trip on condition that some other participant also comes. After some effort, you have taken from each of your participants a number, indicating that this participant will refus...
apps_data_3198
It is now far into the future and human civilization is ancient history. Archaeologists from a distant planet have recently discovered Earth. Among many other things, they want to decipher the English language. They have collected many printed documents to form a dictionary, but are aware that sometimes words are not ...
apps_data_3199
Mirko decided to open a new business—bank vaults. A branch of the bank can be visualized in a plane, vaults being points in the plane. Mirko’s branch contains exactly $L\cdot (A+1+B)$ vaults, so that each point with integer coordinates inside the rectangle with corners $(1, -A)$ and $(L, B)$ contains one vault. The va...