Recently Added DMOJ Problemshttps://dmoj.ca/The latest problems added on the DMOJ: Modern Online Judge websiteenFri, 16 Feb 2018 02:24:24 +0000CCC '18 J5 - Choose your own pathhttps://dmoj.ca/problem/ccc18j5<div><h5>Canadian Computing Competition: 2018 Stage 1, Junior #5</h5>
<p>There is a genre of fiction called choose your own adventure books. These books allow the reader to make choices for the characters which alters the outcome of the story.</p>
<p>For example, after reading the first page of a book, the reader may be asked a choice, such as "Do
you pick up the rock?" If the reader answers "yes", they are directed to continue reading on page \(47\), and if they choose "no", they are directed t...Fri, 16 Feb 2018 02:24:24 +0000https://dmoj.ca/problem/ccc18j5CCC '18 J3 - Are we there yet?https://dmoj.ca/problem/ccc18j3<div><h5>Canadian Computing Competition: 2018 Stage 1, Junior #3</h5>
<p>You decide to go for a very long drive on a very straight road. Along this road are five cities. As you travel, you record the distance between each pair of consecutive cities.</p>
<p>You would like to calculate a distance table that indicates the distance between any two of the cities you have encountered.</p>
<h4>Input Specification</h4>
<p>The first line contains \(4\) positive integers less than \(1\,000\), each represe...Fri, 16 Feb 2018 02:12:11 +0000https://dmoj.ca/problem/ccc18j3CCC '18 J2 - Occupy parkinghttps://dmoj.ca/problem/ccc18j2<div><h5>Canadian Computing Competition: 2018 Stage 1, Junior #2</h5>
<p>You supervise a small parking lot which has \(N\) parking spaces.</p>
<p>Yesterday, you recorded which parking spaces were occupied by cars and which were empty.</p>
<p>Today, you recorded the same information.</p>
<p>How many of the parking spaces were occupied both yesterday and today?</p>
<h4>Input Specification</h4>
<p>The first line of input contains the integer \(N\) \((1 ≤ N ≤ 100)\). The second and third lines of in...Fri, 16 Feb 2018 02:06:33 +0000https://dmoj.ca/problem/ccc18j2CCC '18 J1 - Telemarketer or not?https://dmoj.ca/problem/ccc18j1<div><h5>Canadian Computing Competition: 2018 Stage 1, Junior #1</h5>
<p>Here at the Concerned Citizens of Commerce (CCC), we have noted that telemarketers like to use
seven-digit phone numbers where the last four digits have three properties. Looking just at the last
four digits, these properties are:</p>
<ul>
<li>the first of these four digits is an \(8\) or \(9\);</li>
<li>the last digit is an \(8\) or \(9\);</li>
<li>the second and third digits are the same.</li>
</ul>
<p>For example, if the...Fri, 16 Feb 2018 02:05:14 +0000https://dmoj.ca/problem/ccc18j1CCC '18 S5 - Maximum Strategic Savingshttps://dmoj.ca/problem/ccc18s5<div><h5>Canadian Computing Competition: 2018 Stage 1, Senior #5</h5>
<p>A long time ago in a galaxy far, far away, there are N planets numbered from \(1\) to \(N\). Each planet has \(M\) cities numbered from \(1\) to \(M\). Let city \(f\) of planet \(e\) be denoted as \((e, f)\).</p>
<p>There are \(N \times P\) two-way flights in the galaxy. For every planet \(e\) \((1 ≤ e ≤ N)\), there are \(P\) flights numbered from \(1\) to \(P\). Flight \(i\) connects cities \((e, a_i)\) and \((e, b_i)\) an...Fri, 16 Feb 2018 01:42:13 +0000https://dmoj.ca/problem/ccc18s5CCC '18 S4 - Balanced Treeshttps://dmoj.ca/problem/ccc18s4<div><h5>Canadian Computing Competition: 2018 Stage 1, Senior #4</h5>
<p>Trees have many fascinating properties. While this is primarily true for trees in nature, the concept of trees in math and computer science is also interesting. A particular kind of tree, a <em>perfectly balanced tree</em>, is defined as follows.</p>
<p>Every perfectly balanced tree has a positive integer <em>weight</em>. A perfectly balanced tree of weight \(1\) always consists of a single node. Otherwise, if the weight of...Fri, 16 Feb 2018 01:35:42 +0000https://dmoj.ca/problem/ccc18s4CCC '18 S3 - RoboThieveshttps://dmoj.ca/problem/ccc18s3<div><h5>Canadian Computing Competition: 2018 Stage 1, Senior #3</h5>
<p>A robot has stolen treasure from a factory and needs to escape without getting caught. The factory
can be modelled by an \(N\) by \(M\) grid, where the robot can move up, down, left, or right.</p>
<p>Each cell of the grid is either empty, a wall, a camera, a conveyor, or the robot’s initial position.
The robot can only walk on empty cells (denoted by <code>.</code>) or conveyors. The first row, last row, first
column and la...Fri, 16 Feb 2018 01:29:01 +0000https://dmoj.ca/problem/ccc18s3CCC '18 S2 - Sunflowershttps://dmoj.ca/problem/ccc18s2<div><h5>Canadian Computing Competition: 2018 Stage 1, Junior #4, Senior #2</h5>
<p>Barbara plants \(N\) different sunflowers, each with a unique height, ordered from smallest to largest,
and records their heights for \(N\) consecutive days. Each day, all of her flowers grow taller than they
were the day before.</p>
<p>She records each of these measurements in a table, with one row for each plant, with the first row
recording the shortest sunflower's growth and the last row recording the tallest...Fri, 16 Feb 2018 00:47:44 +0000https://dmoj.ca/problem/ccc18s2CCC '18 S1 - Voronoi Villageshttps://dmoj.ca/problem/ccc18s1<div><h5>Canadian Computing Competition: 2018 Stage 1, Senior #1</h5>
<p>In the country of Voronoi, there are \(N\) villages, located at distinct points on a straight road. Each
of these villages will be represented by an integer position along this road.</p>
<p>Each village defines its <em>neighbourhood</em> as all points along the road which are closer to it than
to any other village. A point which is equally close to two distinct villages \(A\) and \(B\) is in the
neighbourhood of \(A\) and a...Fri, 16 Feb 2018 00:41:45 +0000https://dmoj.ca/problem/ccc18s1CTU Open Contest 2017 - Treetop Walkwayhttps://dmoj.ca/problem/ctuopen2017k<div><p>The amusement park is a real landscape park which means that there are significant portions
of forest standing among the attractions. A huge treetop walkway allows the visitors to explore
the unusual world of tree canopies and enjoy spectacular views of hills and lakes in the region.</p>
<p>The walkway consists of wooden platforms installed close to the treetops in different heights
above the ground and connected by narrow wooden paths. Each path connects exactly two
platforms. Number of...Thu, 15 Feb 2018 21:05:19 +0000https://dmoj.ca/problem/ctuopen2017kCTU Open Contest 2017 - Punching Powerhttps://dmoj.ca/problem/ctuopen2017j<div><p>The park management finally decided to install some popular boxing machines at various strategic
places in the park. In fact, to compensate for the previous lack of machines, they decided to
install as many machines as possible. Surprisingly enough, the park is not going to be choked
with new machines because there are some quite serious legal limitations regarding the locations
of the machines. The management has marked all possible boxing machine locations and their
respective coordina...Thu, 15 Feb 2018 20:17:34 +0000https://dmoj.ca/problem/ctuopen2017jCTU Open Contest 2017 - Dark Ride With Monstershttps://dmoj.ca/problem/ctuopen2017i<div><p>A narrow gauge train drives the visitors through the sequence of chambers in the Dark Ride
attraction. The chambers are occupied by IT monsters which are specially programmed to scare
the visitors in various wicked ways. There is one monster in each chamber. For strange and
obscure reasons, some of the monsters might have been installed in wrong chambers. The task of
Freddie and Morcia, who themselves are employees and not monsters, is to reinstall the monsters
in the correct chambers.</...Thu, 15 Feb 2018 19:52:22 +0000https://dmoj.ca/problem/ctuopen2017iCTU Open Contest 2017 - Ice Cream Sampleshttps://dmoj.ca/problem/ctuopen2017h<div><p>To encourage visitors active movement among the attractions, a circular path with ice cream
stands was built in the park some time ago. A discount system common for all stands was
also introduced. When a customer buys ice cream at some stand, he is automatically granted a
discount for one day at the next stand on the path. When visitors start at any stand and follow
systematically the discount directions to the next stands, they eventually traverse the whole
circular path and return back...Thu, 15 Feb 2018 19:26:55 +0000https://dmoj.ca/problem/ctuopen2017hCTU Open Contest 2017 - Shooting Galleryhttps://dmoj.ca/problem/ctuopen2017g<div><p>The popular shooting gallery in the park is an attraction which is simple and intricate at the same
time. It consists of a row of ducks sitting on one horizontal perch. The ducks are not necessarily
all of the same kind, some of them may belong to different, albeit easily distinguishable, species.</p>
<p>The shooting proceeds in rounds. In each round, the shooter fires two shots. Each shot can hit
at most one duck. A round is considered to be a good round if the shooter hits two ducks of...Thu, 15 Feb 2018 19:16:34 +0000https://dmoj.ca/problem/ctuopen2017gCTU Open Contest 2017 - Forest Picturehttps://dmoj.ca/problem/ctuopen2017f<div><p>The game “Draw a forest picture” is quite popular among younger visitors of the amusement
park. The number of players in the game is virtually unlimited and nearly everybody becomes
a winner. The game is simple. At the beginning, a leader of the game describes briefly a picture
of a forest which he or she had seen recently. Then the players are given some paper and crayons
and they have to reproduce the image as best as they can. Everybody who hands in at least
partial image of virtually...Thu, 15 Feb 2018 18:58:04 +0000https://dmoj.ca/problem/ctuopen2017fCTU Open Contest 2017 - Equinox Roller Coasterhttps://dmoj.ca/problem/ctuopen2017e<div><p>Equiroaster is an abbreviation of EQUInox ROller coASTER, a new and grand attraction which
is going to be built in the park vicinity the next year.</p>
<p>The name of the roller coaster comes from the fact that it is the first roller coaster of its class
with a construction and shape directly linked to major astronomical events. Twice a year, at
equinox, the visitors will enjoy an unforgettable ride enhanced by additional visual effects. Also,
the advertising value of equinox rides is ex...Thu, 15 Feb 2018 18:40:28 +0000https://dmoj.ca/problem/ctuopen2017eCTU Open Contest 2017 - Go Northwest!https://dmoj.ca/problem/ctuopen2017d<div><p>Go Northwest! is a game usually played in the park main hall when occasional rainy weather
discourages the visitors from enjoying outdoor attractions.</p>
<p>The game is played by a pair of players and it is based entirely on luck, the players can hardly
influence its outcome.</p>
<p>The game plan consists of one large map on the wall with N distinct towns displayed on it.
Before the start of the game, the leader of the game hands a bowl filled with N identical balls to
each player. Insi...Thu, 15 Feb 2018 18:40:27 +0000https://dmoj.ca/problem/ctuopen2017dCTU Open Contest 2017 - Chessboard Dancinghttps://dmoj.ca/problem/ctuopen2017c<div><p>Amusement park anniversary organizing group invited a prominent dance company to perform
surprise theme dances at the anniversary celebrations. The company prepared four dances with
chess theme, conveniently named King performance, Knight performance, Bishop performance
and Rook performance.</p>
<p>Each dance is performed by a number of teams of dancers. The unusual setting in the amusement
park seems to cause difficulties to a few sensitive company members, however. The main
choreograph...Thu, 15 Feb 2018 18:21:55 +0000https://dmoj.ca/problem/ctuopen2017cCTU Open Contest 2017 - Pond Cascadehttps://dmoj.ca/problem/ctuopen2017b<div><p>The cascade of water slides has been installed in the park recently and it has to be tested. The
cascade consists of some number of reservoirs, or “ponds” for short, which are linked into a single
sequence connected by water slides. Visitors are expected to start the journey in the topmost
pond, then to be washed into subsequent lower ponds, and finally end the journey in the last
pond of the cascade, which is also the lowest pond of the cascade. The journey spans all ponds
in the cascad...Thu, 15 Feb 2018 17:46:03 +0000https://dmoj.ca/problem/ctuopen2017bCTU Open Contest 2017 - Amusement Anticipationhttps://dmoj.ca/problem/ctuopen2017a<div><p>It is was late Saturday morning at the end of October. The amusement park was going to be
open that afternoon for the first time after months of prolonged reconstruction.</p>
<p>Josse and Murry were sitting in the basement of the office building at the park gate. They have
just finished debugging their advanced AI system management of all fantastic attractions in the
park. “Work is done,” said Josse. “Now for some amusement. Can you think of any algorithmic
problem?”</p>
<p>“Yes, of cour...Thu, 15 Feb 2018 07:16:37 +0000https://dmoj.ca/problem/ctuopen2017aMock CCC '18 Contest 5 S5 - Carol's Cute Constructionhttps://dmoj.ca/problem/nccc5s5<div><p>Carol wants to go to California!</p>
<p>Tudor recently gave Carol a game with similarities to Boggle. There is an \(N \times N\) grid of letters,
all of which are either <code>C</code>, <code>A</code>, <code>L</code>, or <code>I</code>. In a single turn, Carol must select a <code>C</code>, an <code>A</code>, an <code>L</code>,
and an <code>I</code> such that the <code>C</code> and <code>A</code> touch in at least one corner, as do the <code>A</code> and <code>L</code> as well as the <cod...Tue, 13 Feb 2018 05:24:40 +0000https://dmoj.ca/problem/nccc5s5Mock CCC '18 Contest 5 S4 - Carol's Cute Conquesthttps://dmoj.ca/problem/nccc5s4<div><p>Carol thought she was done with the CCC, but the CCC wasn't done with her.</p>
<p>Having arrived at Google, Carol realized that the scale at which she was thinking was way too small.
What would happen if she had to consider strings with millions of letters?</p>
<p>The CCC, recognizing this opportunity, struck. They sent her an email containing many occurrences of the letter <code>C</code>.</p>
<p>Carol realized that, in order for her to be truly free of the CCC, she would have to be okay...Tue, 13 Feb 2018 05:24:38 +0000https://dmoj.ca/problem/nccc5s4Mock CCC '18 Contest 5 J5/S3 - Carol's Cute Chasehttps://dmoj.ca/problem/nccc5j5s3<div><p>Having successfully passed his background check, Tudor is finally on his way to Google!
Little does he know that Carol is attempting to surprise him by arriving there first.</p>
<p>Carol is currently in Canada and needs to sneak over to Google. This will require taking
several flights.</p>
<p>Because Carol is flying Air Canada, she is sure that she will be accepted at all intermediate
airports and eventually be able to arrive at Google. However, a recent law called The Last
Endeavor rece...Tue, 13 Feb 2018 05:24:34 +0000https://dmoj.ca/problem/nccc5j5s3Mock CCC '18 Contest 5 J4/S2 - Carol's Cute Carolshttps://dmoj.ca/problem/nccc5j4s2<div><p>Carol enjoys caroling.</p>
<p>Having finished writing the CCC, Carol is now free from the constraints that CCC put on her
blade and soul. She now moves to a different problem - giving out gifts for Valentine's Day.</p>
<p>She has a list of \(N\) gifts that she needs to give out to her \(N\) favorite people. Each gift
has a distinct importance value \(v_i\), where lower values of \(v_i\) denote more importance,
in the vein of being able to say that the person receiving the gift with value...Tue, 13 Feb 2018 05:24:32 +0000https://dmoj.ca/problem/nccc5j4s2Mock CCC '18 Contest 5 J3/S1 - Carol's Cute Centerhttps://dmoj.ca/problem/nccc5j3s1<div><p>Mastering the art of counting spikes was a tough activity for Carol, but she did it
gracefully and uneventfully.</p>
<p>Even though she was successfully able to count the spikes on all of the cacti and
figure out the most frequent counts of spikes for her cacti, she still did not feel
as though this provided her with an adequate reservoir of cuteness that she could
rely on.</p>
<p>Desperate for more statistics from which she can derive cuteness, Carol starts attempting
to study math. She...Tue, 13 Feb 2018 05:24:29 +0000https://dmoj.ca/problem/nccc5j3s1