task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Almost Sorted Description: In this sorting algorithm, some elements get sorted sooner than others. Given an array, and an element $Q$, it is your task to determine the state of the array when element $Q$ is first sorted. ## Input Input begins with a line containing a single integer $n$, the length of...
26,200
Almost Union-Find Description: I hope you know the beautiful Union-Find structure. In this problem, you’re to implement something similar, but not identical. The data structure you need to write is also a collection of disjoint sets, supporting 3 operations: Union the sets containing $p$ and $q$. If $p$ a...
26,201
Alphabet Description: A string of lowercase letters is called alphabetical if some of the letters can be deleted so that the only letters that remain are the letters from ‘a’ to ‘z’ in order. Given a string $s$, determine the minimum number of letters to add anywhere in the string to make it alphab...
26,202
Alphabet Animals Description: Given the last animal name said before your turn and a list of all names not yet used, can you make it through this turn? If so, can you make sure to eliminate the next player? ## Input The first line of input contains a single word, the animal that the previous player just ...
26,203
Alphabet Spam Description: A very simple and fast spam detection mechanism is based on the ratios between whitespace characters, lowercase letters, uppercase letters, and symbols. Symbols are defined as characters that do not fall in one of the first three groups. ## Input The input consists of: * o...
26,204
Alphabetical Aristocrats Description: It is the year 1830 of our Lord, 15 years after the Kingdom of the Netherlands gained independence from its French oppressors. You are secretary of state and aide to his highness William I, Grand Duke of Luxembourg and King of the Netherlands – an empire that is de...
26,205
Alpine Agility Description: Alice and Bob have spent a wonderful day hitting the slopes at their favourite ski hill. To make things more interesting they’ve come up with a game. Both start at the Northwest-most point on the hill and race to the Southeast-most point. However, they are not racing to see ...
26,206
Alternating Algorithm Description: Incidentally, you also have an array of $n+1$ integers, $a_0, a_1, \ldots , a_ n$, that you need to sort. To make good use of the large number of cores on your CPU, you have devised a parallel sorting algorithm in which there is a dedicated core for comparing each adjacen...
26,207
Alternating Current Description: Fredrik is at home, playing with a custom-built model railway which he is very proud of. The railway consists of $N$ segments connected in a circle, numbered $1, 2, \dots , N$ in clockwise order. Electricity to the train is provided through $M$ curved wires that...
26,208
Alternative Anagram Description: Consider a string of $N$ letters, where $N$ is an even number. Rearrange the letters such that all $N/2+1$ substrings of length $N/2$ are different. ## Input A single line containing string $S$ of length $N$, where $2 \leq N \leq 10^5$ and $N$ is even. The string consists of ...
26,209
Alternative Bracket Notation Description: Balanced closed bracket or parenthesis statements are ones where each opening bracket is matched with a closed bracket later in the string. Notice how each closed parenthesis matches to the most recent unmatched open parenthesis. Define an alternative bracket not...
26,210
Alto Singing Description: Anton has chosen a particular song he likes very much that he wants the choir to sing. There is only a slight problem – the song is not at all suited for his particular vocal range. Anton has the alto vocal range, and wants to make sure that the most important part of the piec...
26,211
Altruistic Amphibians Description: The frogs realize that if a frog $A$ climbs up on the back of frog $B$ before it jumps, the first frog $A$ stands a better chance of escaping the pit: it can escape if $h_ B+l_ A$ is strictly larger than the depth of the pit. Furthermore, if frog $B$ carrying fro...
26,212
Always Know Where Your Towel Is Description: Arthur wants to go swimming. Another chance to use his favourite towel! He is concerned that if he leaves it out at the pool then someone might take it. So he keeps it in a locker. Accessing the lockers is done in a peculiar way. One has to use an app on th...
26,213
Amalgamated Artichokes Description: Fatima has done some previous analyses and has found that the stock price over any period of time can be modelled reasonably accurately with the following equation: where $p$, $a$, $b$, $c$ and $d$ are constants. Fatima would like you to write a program to determine...
26,214
Amanda Lounges Description: 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 plac...
26,215
Amazing Adventures Description: The amazing game Pokenom Go has just been released. Pokenom trainers can now travel the world, capture Pokenom in the wild and battle each other! Bash and Cee are two students who have recently dropped out of university to pursue their childhood dream of becoming Pokeno...
26,216
Amazing Race Description: The scavenger hunt must be completed within $T$ minutes. That is, the time between leaving the starting location and arriving at the ending location must be no more than $T$ minutes. In addition, some tasks have a specific deadline $d_ i$, meaning that the task must be complet...
26,217
Amazing Race Atlantic Description: The Amazing Race: Atlantic Canada Edition (ARACE) has decided to do preselection to narrow down the thousands of registrant teams. To select only the best ones, teams must qualify by racing to the next location on a path of road segments, each of which is marked with ...
26,218
Amazing Whispers Description: A group of friends want to play the game Amazing Whispers, where a secret phrase is transferred among a collection of people according to the following rules: You have $N \times M$ people arranged in $M$ groups of $N$ people each. A secret phrase is divided into $N$ d...
26,219
Ambiguous Result Description: The ACM (Advanced Cosmos Monitor) recorded a set of messages transmitted by alien race of Space Invaders. Unfortunately, the antenna used for recording only handles lower frequencies representing numbers and two arithmetical operators in space-invaderian language, while al...
26,220
Amerískur vinnustaður Description: You have recently begun your job as a civil engineer, or “byggingarverkfræðingur” in Icelandic. You spend most of your day designing road systems, but since you are in the United States of America, everything is measured in football fields. You have decided to write a p...
26,221
Among Ourselves Description: You are playing the game “Among Ourselves.” There are $n$ players numbered from $1$ to $n$ in this game, and you are player number $1$. Each player is either a crewmate or an imposter. You are a crewmate. During the voting phase of the game, the players exchange accusa...
26,222
Amsterdam Distance Description: Your friend from Manhattan is visiting you in Amsterdam. Because she can only stay for a short while, she wants to see as many tourist attractions in Amsterdam in as little time as possible. To do that, she needs to be able to figure out how long it takes her to walk fro...
26,223
An Easy Array Problem Description: This is an array problem. Given $N$ numbers, $A_1, \dots A_ N$, answer $Q$ queries as follows: Given $L, R$ where $R - L + 1 \geq 4$, among all possible $L < X < Y < R$, maximise $A_ L \times A_ X \times A_ Y \times A_ R$. Output on a single line thi...
26,224
An I for an Eye Description: Ken has been having trouble lately staying under the word limit in Twitter, so he’s decided to write a little front-end program which will take in text and shorten it using a fixed set of abbreviations for commonly used letter sequences. Those abbreviations are shown in the...
26,225
An Industrial Spy Description: Industrial spying is very common for modern research labs. I am such an industrial spy – don’t tell anybody! My recent job was to steal the latest inventions from a famous math research lab. It was hard to obtain some of their results but I got their waste out of a docume...
26,226
Anagram Counting Description: An anagram is a reordering of the letters in a word of phrase. For example, you can rearrange the letters of terraced to get the word retraced. Rearranging them some more will give you the word cratered. You can even make dactrere and redatrec, which are both anagrams of t...
26,227
Andrew the Ant Description: Andrew the Ant is fascinated by the behavior of his friends. Thousands of them are marching their paths on and on. They can build highly organized ant-hills. Sometimes, however, they act a little bit stupidly. Recently, Andrew watched his fellow ants marching on top of a lo...
26,228
Animal Classification Description: Alice and Bob are biologists. They like to group animals using classification trees. A classification tree is a binary tree where the leaves are labeled by the animals. For example, Figure 1 below shows the classification of $5$ animals (labeled as $1, 2, 3, 4, 5$) b...
26,229
Anime Shops Description: There are $n$ cities and $m$ roads. Each road is bidirectional and connects two cities. It is also known that $k$ cities have an anime shop. If you live in a city, you of course know the local anime shop, well, if there is one. You would like to find the nearest anime ...
26,230
Annoyed Coworkers Description: It’s another day in the office, and you’re a mastermind of not doing any work yourself. Instead, you’ll go to your coworkers for “help,” but secretly have them do all the work. You’ve determined that the more one of your coworkers helps you, the more annoyed they become....
26,231
Another Brick in the Wall Description: The construction worker previously known as Lars has many bricks of height $1$ and different lengths, and he is now trying to build a wall of width $w$ and height $h$. Since the construction worker previously known as Lars knows that the subset sum problem...
26,232
Another Candies Description: A class went to a school trip. And, as usually, all $N$ kids have got their backpacks stuffed with candy. But soon quarrels started all over the place, as some of the kids had more candies than others. Soon, the teacher realized that he has to step in: "Everybody, liste...
26,233
Another Coin Weighing Puzzle Description: You have some bags of coins. Each bag contains exactly $k$ coins. Exactly one bag contains only counterfeit coins (we’ll call this the fake bag), while all other bags contain only real coins. All real coins weigh exactly the same number of grams. All counte...
26,234
Another Dice Game Description: In the game Pickomino1 one has to throw 8 dice to reach at least a certain target score. The rules are as follows: * The dice contain the values 1, 2, 3, 4, 5 and worm. The dice are fair, so all outcomes are equally likely. * The game is started by throwing all ...
26,235
Another Query on Array Problem Description: Given an array of integers $A_1, A_2, \ldots , A_ N$ and the initial value of all elements are $0$. Now you are given $M$ queries, each belongs to one of three following types: * $0$ $x$ $y$: Find the sum of all elements from index $x$ to index $y$ m...
26,236
Another Substring Query Problem Description: You are given a string $s$ and several queries. Each query consists of a string $t$ and an integer $k$. For each query, determine the $k^{th}$ position in $s$ where a substring matching $t$ starts. If $t$ occurs fewer than $k$ times in $s$, print $-1$. ...
26,237
Ant Typing Description: Consider a configurable keyboard where keys can be moved about. An ant is walking on the top row of this keyboard and needs to type a numeric string. The ant starts on the leftmost key of the top row, which contains $9$ keys, some permutation of the digits from $1$ to $9$. O...
26,238
Antenna Analysis Description: Åke has heard that there may be some suspicious 5G radiation in his city. To test this, he uses the antenna on his roof to measure the 5G level each day. However, he does not know how he should analyze the data. We are given the measurements for $n$ consecutive days as a list...
26,239
Antenna Placement Description: The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they got the job, is their discovery of a new, highly noise resistant, antenna. It is called 4DAir, and comes in four...
26,240
Anthony and Cora Description: Anthony and Cora play a very exciting game. Initially, Anthony has $N$ points and Cora has $M$ points. The game then goes on for several rounds, during each round, either Anthony wins or Cora wins, the loser of the round loses $1$ point while nothing happens to the...
26,241
Anthony and Diablo Description: Anthony has a pet hamster named Diablo. Diablo enjoys having lots of space to move around, so Anthony wants to build him a cage that covers as much area as possible. However, Diablo also likes to dig and hide very much, and when he does, it is an absolute pain for Anthony t...
26,242
Anti-Palindrome Description: ## Input The input consists of one line of text as specified above. The input line will not be longer than 80 characters, and contains at least one alphabetic character. ## Output Print “Palindrome" if the text contains or is itself a palindrome, or “Anti-palindrome" if ther...
26,243
Antialiasing Description: To reduce aliasing effects, computer graphics systems render a polygon by setting the brightness of each pixel proportional to the area of the pixel inside the polygon. If a pixel is completely inside the polygon, that pixel is set to the brightest intensity. If only half of t...
26,244
Antiarithmetic? Description: A sequence $a_{1}, a_{2}, a_{3}, \ldots $ is an arithmetic progression if there exists a constant $c$ such that $a_{i} - a_{i+1} = c$ for $i = 1, 2, 3, \ldots $. A permutation of $n$ is a bijective function of the initial $n$ natural numbers: $0, 1, \ldots n-1$. A ...
26,245
Antimatter Rain Description: You’ve heard of acid rain but have you heard of antimatter rain? Antimatter rain is so potent that when it comes into contact with another object, it immediately disintegrates both itself and the object. Kayla’s job as a SpaceFleet Researcher is gathering weather data on ex...
26,246
Antivirus Description: A computer network has been infected by evil viruses, so Hacke Hackspett 1 has been tasked with removing them. Each computer in the network has some number of viruses or antiviruses. There can never be both viruses and antiviruses in the same computer at the same time because th...
26,247
Ants Description: An army of ants walk on a horizontal pole of length $l$ cm, each with a constant speed of $1$ cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off it. When two ants meet they turn back and start walking in opposite directions. We know the original pos...
26,248
Any Pythagorean Triple Description: You are given a circumference $n$ and want to find a right-angled triangle with integer side lengths that has a right angle and this circumference. No side can have length $0$, nor a negative length. ## Input The first and only line of input contains a positive integer ...
26,249
Apaxiaaaaaaaaaaaans! Description: The ancient and mysterious Apaxian civilization, which we most certainly did not make up, continues to confound the researchers at the Oriental Institute. It turns out that the Apaxians had a peculiar naming system: the more letters in your name, the higher your status...
26,250
Aperiodic Appointments Description: Nick has always struggled with maintaining habits. The problem is that he just can’t stop maintaining them. If Nick does something $K$ times in a row, he has to keep doing it forever. Luckily, he has started visiting Dr Patternson, an expert in PBT (Pattern Breaking...
26,251
Apostrophe Catastrophe Description: Apostrophes and double quotes tend to get badly encoded by systems, causing them to print back things like &#x27; 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 ...
26,252
Appalling Architecture Description: You have recently been hired as an architect for the BAPC (Bureau of Architecture and Promising Constructions), responsible for top-quality buildings such as the Tower of Pisa. However, in the past couple of weeks, some of the structures that the BAPC have made have ...
26,253
Apparatus Description: 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 s...
26,254
Appeal to the Audience Description: You are the director of the upcoming Bordfite Arena Progaming Competition. You have invited a bunch of players and are now setting up the matches for the knockout tournament that will determine the winner. As you may know, Bordfite Arena is a game that heavily reward...
26,255
Apple Delivery Description: Ingrid, the apple farmer, has just harvested a huge amount of apples that she intends to give to herself and her neighbours. Her neighbourhood can be represented by an infinite plane where every point with integer coordinates contains exactly one house. Ingrid’s house is loc...
26,256
Apple Market Description: You are managing a market with some stores. The stores are arranged in an $n \times m$ grid. Each store sells apples. Apples cost exactly $1$ Malaysian Ringgit per apple at every store. There will be several customers who walk through this market. Each customer will only ...
26,257
Apple Orchard Description: Farmer John has many apple trees on his farm. Each apple tree has a circular area that provides shade during the hot summer. Farmer John is creating a pen for his cows and has several locations in mind. For each fenced off area he wants to know the percentage of that proposed...
26,258
Apples, Cherries, and Mangos Description: 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 Singapor...
26,259
Aquarium Description: The aquarium at which you work is hoping to expand its meagre selection of aquatic life, but lacks the funds to do so. You have been tasked to help promote the aquarium by taking photos of the two exhibits. Taking the first photo went swimmingly, because the catfish were very coop...
26,260
Aquarium Tank Description: You just bought an “artistic” aquarium tank that has an interesting shape, and you poured $L$ litres of water into the tank. How high is the water in the tank? When you look at this tank from one side, it has the shape of a convex polygon. This polygon has exactly two vertices o...
26,261
Aqueduct Construction Description: After conquering Britannia, the great Roman general Agricola decided all of his new cities should take advantage of the natural springs found aplenty. He appointed his advisor Wessus Waterus to try to find a way to get each town a fresh supply of water. There are man...
26,262
Arable Area Description: The prime minister has recently bought a piece of valuable agricultural land, which is situated in a valley forming a regular grid of unit square fields. ACM would like to verify the transaction, especially whether the price corresponds to the market value of the land, which is...
26,263
Arachnophobia Description: Jimmy is performing in ByteLand today! Anthony the Ant is a huge fan of Jimmy’s music, so he can’t wait to get to the concert. ByteLand consists of of $N$ intersections and $M$ roads. Every road is bidirectional and connects two distinct intersections. Anthony is currently o...
26,264
Arbitrage? Description: If you are going to travel to the World Finals, you cannot rely on Czech Crowns. You would have to exchange your money for various foreign currencies. This problem deals with multiple currencies and their exchange rates. Your task is to verify that some set of exchange rates is ...
26,265
Arboriculture Description: In preparation for the Swedish Coding Cup Finals, the organizing committee is decorating the hall for the award ceremony with beautiful juniper trees. They have designed an arrangement of $N$ trees, each with a specific look. As the resident arborist of the competition, i...
26,266
Arcade! Description: Write a program that computes the expected payout when dropping a ball into the machine! ## Input The input consists of a single test case. The first line contains an integer $N$ ($1 \le N \le 32$) describing the number of rows of the arcade machine. The second line contains ...
26,267
Arcaea Partners Description: In the rhythm game Arcaea, the player can play songs with various partners. Every partner has two skill levels: Frag, and Step. A larger Frag allows playing songs to earn a larger number of fragments, the main resource of the game. A larger Step helps the player progress fa...
26,268
Archaeological Recovery Description: Renowned professor of Egyptology Z Mummer is exploring a newly discovered tomb in Luxor where she finds a mysterious construction. On a wall, there is a row of $k$ pyramid-shaped stone slabs. Each stone features three hieroglyphs: an ankh (top), an eye of Horus (bot...
26,269
Archery Accuracy Description: You are managing an archery team for a competition. Each team member has their own fixed probability of hitting a target. The tournament works in a series of rounds. Your team has the same number of members as there are rounds in the tournament. In each round, exactly one...
26,270
Archimedes Description: Archimedes is the name of a new 2D video game, which is very simple: the player hits start, at which point their avatar moves along an Archimedean spiral starting from the origin. When they hit a button, the avatar detaches from the spiral in the direction it is currently moving...
26,271
Architecture Description: Your brother has won an award at the recent Breakthroughs in Architectural Problems Conference and has been given the once in a lifetime opportunity of redesigning the city center of his favorite city Nijmegen. Since the most striking parts of a city’s layout are the skylines,...
26,272
Arctic Network Description: The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio transceiver and some outposts will in addition hav...
26,273
Ardi, The Hungry Aardvark Description: Ardi the aardvark arrived at the pet shop tired and hungry. Ardi spotted an ant farm on the next shelf, already populated with lots of yummy-looking crispy ants. Amazingly, it was so 2-dimensional that she could see every tunnel and avery ant. Immediately, Ardi be...
26,274
Are You Listening? Description: You’re a top government spy currently at a secret location behind enemy lines (ooooh....exciting!). You have a communication device that allows you to stay in contact with various other operatives that you work with. The broadcast range of the device is adjustable and id...
26,275
Area of Effect Description: Liam (angryneeson52) is playing his favorite tower defense game! This game involves destroying minions of his opponent while defending his own villages. Liam’s favorite attack is an Area of Effect attack. The Area of Effect attack is a perfect circle. Liam simply picks a ce...
26,276
Arithmetic Description: Ever wonder what will happen when you meet a person who uses a different base system to talk about numbers? For example, when you hear someone saying this mysterious number 1010110001 (which is in binary), can you quickly convert it to its decimal form, 689? In Harkerland, everyone...
26,277
Arithmetic Decoding Description: Arithmetic coding is a method to represent a message as a real number $x$ such that $0 \leq x < 1$. We will assume that the message consists only of uppercase ‘A’s and ‘B’s. The two letters have associated probabilities $p_ A$ and $p_ B = 1 - p_ A$ such that $0 ...
26,278
Arithmetic Functions Description: Your task is to implement the following functions in C++: ``` #include "arithmeticfunctions.h" // Compute x^3 int cube(int x){ ... } // Compute the maximum of x and y int max(int x, int y){ ... } // Compute x - y int difference(int x, int y){ ... } ``` ...
26,279
Arm Coordination Description: All the cool kids in town want to become a member of the Bots and Androids Programmer Club (BAPC). To become a member of the club, applicants must show a feat of their skills with a home-made robot that is programmed to perform some tricks. Just like your older brother, yo...
26,280
Army Strength (Easy) Description: Note that this is an easier version of the problem armystrengthhard. The next MechaGodzilla invasion is on its way to Earth. And once again, Earth will be the battleground for an epic war. MechaGodzilla’s army consists of many nasty alien monsters, such as Space Godzi...
26,281
Army Strength (Hard) Description: Note that this is a harder version of the problem armystrengtheasy. The next MechaGodzilla invasion is on its way to Earth. And once again, Earth will be the battleground for an epic war. MechaGodzilla’s army consists of many nasty alien monsters, such as Space Godzil...
26,282
Around and Around We Go Description: In western music, an integer count of time units can be assigned to each syllable to indicate how long that syllable is sung. A rest of one or more time units can be treated as a syllable that simply isn’t sung. If you know the time allocated to each syllable, and...
26,283
Around the Track Description: In order to compare race tracks, we wish to compute their lengths. A racetrack is strictly two-dimensional (no elevation). It is described by two simple polygons, where one is completely contained inside the other. The track is the region between these two polygons. We def...
26,284
Around the track Description: After The Stig’s identity was revealed, the TV show Top Gear is in dire need of a new, tame racing driver to replace him. And of course you have been asked to take the job. However, you are not very fond of driving quickly, and especially not around the twisting and turnin...
26,285
Arranging Adapters Description: It is the day before the NWERC and you and your team are on the train towards Delft. The journey is long and boring but you came up with a good idea: “Let’s do some training”. – silence – You take your laptop out and try to plug it in when you notice that the only sock...
26,286
Arranging Hat Description: Recently the hat has been reading computer science papers in its ample spare time, and of course, being an arranging hat, it is particularly interested in learning more about sorting algorithms. The hat’s new contribution is to a class of algorithms known as lossy sorting al...
26,287
Arranging Wine Description: The host university is organizing a party for this year’s ACM/ICPC contestants with a buffet dinner and $R$ boxes of red wine and $W$ boxes of white wine. Wine boxes are to be arranged into non-empty piles, each pile contains only one type of wine, either white or red. After tha...
26,288
Array Smoothening Description: You’ve just finished writing a random array generator for your competitive programming practical examination problem. However, when you tested it, you noticed that the distribution is skewed; some values may appear much more times than the other values. You wanted to smoo...
26,289
Array of Discord Description: Eris must be careful not to be discovered while performing her sabotage, so she decides to only change a single digit in one of the numbers in Zeus’ answer. The resulting number may not have any leading zeros (unless it becomes equal to zero in which case a single zero dig...
26,290
Arrested Development Description: You are now in charge of two programming interns, and you must develop a large system. There are a number of tasks that need to be completed by the end of the summer. You know how long each intern will take to complete each task, in minutes. Compute the minimum number...
26,291
Arriving on Time Description: Luckily you live in Zürich, which features a large network of extremely punctual trams. Each tram line travels from one place to another at regular intervals, always taking the same time from departure to arrival. It is very easy to change trams, and we assume that it take...
26,292
Art Appreciation Description: Brandon Greg Jr. is an art enthusiast who covered the entirety of the walls of his room with works of art. Brandon’s room is in the shape of a simple polygon (simple means that the polygon does not intersect itself). If Brandon is at point $X$, then he can see all poin...
26,293
Artistic Masterpiece Description: As you know, digital images are often represented as a grid of pixels. Here, let’s assume that we have an infinitely large grid of pixels, with $x$-coordinates and $y$-coordinates ranging from $-\infty $ to $+\infty $. The pixel at $x$-coordinate $x$ and $y$-coordinate $y$...
26,294
Artur Description: 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...
26,295
Artwork Description: A template for an artwork is a white grid of $n \times m$ squares. The artwork will be created by painting $q$ horizontal and vertical black strokes. A stroke starts from square $(x_1,y_1)$, ends at square $(x_2,y_2)$ ($x_1=x_2$ or $y_1=y_2$) and changes the color of all sq...
26,296
As Easy as CAB Description: We all know how to alphabetize a list of distinct words when you know the alphabet: One word may be a prefix of another longer word, in which case the shorter word always comes before the longer word. With any other two words there must be a first place in the words where th...
26,297
Ascending Photo Description: The members of the No-Weather-too-Extreme Recreational Climbing society completed their 100th successful summit today! To commemorate the occasion, we took a picture of all the members standing together in one row, to use for marketing purposes. However, the photograph loo...
26,298
Ask Marilyn Description: Marilyn is by far your favourite bartender, because she turns every order into a game. At the bar, there are three small boxes with doors labelled A, B, and C. When you buy a drink, Marilyn places the bottle in one of the boxes; you don’t know which. Then the following ritual ...
26,299