Recently Added DMOJ Problemshttps://dmoj.ca/2018-08-13T04:23:20+00:00The latest problems added on the DMOJ: Modern Online Judge websiteJOI '13 - Synchronization2018-08-13T04:23:20+00:002018-08-13T04:23:20+00:00https://dmoj.ca/problem/joi13p2<div><h5>JOI Open Contest</h5>
<p>The JOI Co., Ltd. has \(N\) servers in total around the world. Each server contains an important piece of information.
Different servers contain different pieces of information. The JOI Co., Ltd. is now building digital lines
between the servers so that the pieces of information will be shared with the servers. When a line is built between
two servers, pieces of information can be exchanged between them. It is possible to exchange pieces of
information from one ...Dynamic Tree Test (Easy)2018-07-30T18:26:26+00:002018-07-30T18:26:26+00:00https://dmoj.ca/problem/ds6<div><p>Today, we'll be practicing modifications on a tree!</p>
<h4>Input Specification</h4>
<p>The first line contains two integers, \(N\) and \(M\), denoting that there are \(N\) vertices and \(M\) queries.</p>
<p>Then there are \(N\) integers on the next line, each containing one number: the initial weight of each vertex.</p>
<p>Then there are \(N-1\) lines, each line containing two integers \(x\) and \(y\), denoting that there is an edge between \(x\) and \(y\) in the tree.</p>
<p>Then next ...BOI 2011 P5 - Time Is Money2018-07-14T17:38:14+00:002018-07-14T17:38:14+00:00https://dmoj.ca/problem/boi2011p5<div><p>The NetLine company wants to offer broadband internet to \(N\) towns. For this, it suffices to construct a network of \(N-1\) broadband links between the towns, with the property that a message can travel from any town to any other town on this network. NetLine has already identified all pairs of towns between which a direct link can be constructed. For each such possible link, they know the cost and the time it would take to construct the link.</p>
<p>The company is interested in minimi...Bank Notes2018-07-07T17:54:55+00:002018-07-07T17:54:55+00:00https://dmoj.ca/problem/banknotes<div><p><strong>Note: This problem is an easier version of the POI problem Bank Notes from 2005.</strong></p>
<p>The Byteotian Bit Bank (BBB) has the largest network of cash dispensers in the whole Byteotia. The BBB have decided to improve their dispensers and have asked you for help. The legal tender in Byteotia are bank notes of denominations \(b_1, \dots, b_n\). The BBB have concluded that the cash dispensers are to pay every sum in the smallest possible total number of notes.</p>
<p><strong>...A Knapsack Problem2018-07-07T16:16:47+00:002018-07-07T16:16:47+00:00https://dmoj.ca/problem/knapsack<div><p>Roger and George run a transport company.</p>
<p>One day their boss Victor tells them to transport some subset of the \(N\) goods to another warehouse. Roger observes that there are \(n_i\) of the \(i\)th item, each taking up \(v_i\) volume in their truck, and will give them a profit of \(p_i\) each.</p>
<p>George is looking at the trucks, and observes that there are \(M\) of these trucks. The \(i\)th truck has a capacity of \(c_i\), but will cost \(f_i\) dollars for refueling. <strong>T...Double Doors Regional P6 - Tudor Learns More DDR2018-06-25T04:48:34+00:002018-06-25T04:48:34+00:00https://dmoj.ca/problem/ddrp6<div><p>Tudor is learning how to play Dance Dance Revolution!</p>
<p>Tudor is good at stepping to the beat, but is struggling to deal with more complex note patterns. He decides to focus on \(N\)-step sequences of notes.</p>
<p>There are four different directions that one can step in Dance Dance Revolution - up, down, left, and right. This means there are \(4^N\) different \(N\)-step sequences of notes.</p>
<p>A <em>spin</em> is defined as four consecutive steps that match a cyclic shift of eith...Double Doors Regional P5 - Tudor Eats Ice Cream Cones2018-06-25T04:48:23+00:002018-06-25T04:48:23+00:00https://dmoj.ca/problem/ddrp5<div><p>Tudor likes ice cream cones!</p>
<p>One day, Tudor travels to an ice cream convention to eat ice cream. There are \(N\) stands, numbered \(1\) through \(N\). Stand \(k\)
is serving flavor \(\left\lceil \frac{k}{\sqrt{N}} \right\rceil\).</p>
<p>Each of the stands charges a certain price for ice cream, which Tudor interprets as a signal of the quality of the ice cream.
Tudor has strong flavor preferences and will decide to order ice cream from two stands within certain flavor constraints, ...Double Doors Regional P4 - Tudor Teaches Jason How To Be Productive2018-06-25T04:48:01+00:002018-06-25T04:48:01+00:00https://dmoj.ca/problem/ddrp4<div><p>Tudor is teaching Jason how to be productive!</p>
<p>One day, Tudor decides that Jason isn't taking his work seriously enough, and installs some
software to monitor Jason's monitor. Jason is now only allowed to type strings which are in a whitelist.</p>
<p>Jason has already written some string and wishes to turn it into another string. In a single second, he
can either insert a character, delete a character, or change some character in the string into another one.
Note that, per the whit...Double Doors Regional P3 - Tudor and the Pusheens2018-06-25T04:47:32+00:002018-06-25T04:47:32+00:00https://dmoj.ca/problem/ddrp3<div><p>Tudor likes pusheens!</p>
<p>Pusheen Boi has recently requested for a <code>/pusheen</code> command to be added in Slack, so that he can spam Slack with
pusheens.</p>
<p>Meanwhile, Tudor's farm of \(N\) servers has gotten to be rather large. There are \(M\) pairs of servers that are connected and therefore can directly communicate with each other.
A server can vacuously communicate with itself. All servers can communicate with each other, perhaps by using intermediate servers.</p>
<p>Pus...Double Doors Regional P2 - Tudor Learns DDR2018-06-25T04:47:19+00:002018-06-25T04:47:19+00:00https://dmoj.ca/problem/ddrp2<div><p>Tudor is learning how to play Dance Dance Revolution!</p>
<p>Tudor is good at stepping to the beat, but is struggling to deal with more complex note patterns.
He decides to focus on three-step sequences of notes.</p>
<p>There are four different directions that one can step in Dance Dance Revolution - up, down,
left, and right. Note that up and down are in opposite directions, and left and right are in opposite
directions. This means there are 64 different three-step sequences of notes.</...Double Doors Regional P1 - Tudor Gets a Goat2018-06-25T04:47:07+00:002018-06-25T04:47:07+00:00https://dmoj.ca/problem/ddrp1<div><p>Tudor likes goats!</p>
<p>One day, Tudor finds himself inside a mall, the Honty Mall. He is participating in a
game show where he has the chance to either win a goat or a car.
In the rewards segment of the game show, Tudor gets to select one of three rooms, each of which is
blocked from view by a set of double doors. Behind one set of double doors is a car, which Tudor doesn't
want. Behind each of the other two sets of double doors is a goat, which Tudor will take home and nurture.
Tudo...Maintaining a Sequence2018-06-16T21:37:32+00:002018-06-16T21:37:32+00:00https://dmoj.ca/problem/seq2<div><p>Please write a program that maintains a sequence, supporting the following 6 operations:</p>
<table class="table">
<tr>
<th>
Operation</th>
<th>
Input Format</th>
<th>
Description</th></tr>
<tr>
<td>
1. Insert</td>
<td>
<tt>
INSERT posi tot c<sub>1</sub> c<sub>2</sub> ... c<sub>tot</sub></tt></td>
<td>
After the \(posi\)-th number in the current sequence, insert a total of \(tot\) numbers: \(c_1, c_2, \ldots, c_{tot}\). Insertion to the beginning of the sequence will have \(posi\) equal ...APIO '18 P3 - Duathlon2018-06-15T22:32:15+00:002018-06-15T22:32:15+00:00https://dmoj.ca/problem/apio18p3<div><p>The Byteburg's street network consists of \(n\) intersections linked by \(m\) two-way street segments. Recently, the Byteburg was chosen to host the upcoming duathlon championship. This competition consists of two legs: a running leg, followed by a cycling leg.</p>
<p>The route for the competition should be constructed in the following way. First, three distinct intersections \(s\), \(c\), and \(f\) should be chosen for start, change and finish stations. Then the route for the competitio...APIO '18 P1 - New Home2018-06-15T19:05:43+00:002018-06-15T19:05:43+00:00https://dmoj.ca/problem/apio18p1<div><p>Wu-Fu Street is an incredibly straight street that can be described as a one-dimensional number line, and each building’s location on the street can be represented with just one number. Xiao-Ming the Time Traveler knows that there are \(n\) stores of \(k\) store-types that had opened, has opened, or will open on the street. The \(i\)-th store can be described with four integers: \(x_i\), \(t_i\), \(a_i\), \(b_i\), representing the store’s location, the store’s type, the year when it star...Fibonacci Sequence (Harder)2018-06-05T02:28:43+00:002018-06-05T02:28:43+00:00https://dmoj.ca/problem/fibonacci2<div><p>[user:quantum] is not feeling well today, and has decided to create a more painful version of the <a href="/problem/fibonacci">simple Fibonacci problem</a>.</p>
<p>Recall that the Fibonacci sequence is a well known sequence of numbers in which</p>
<p>\[F(n) = \begin{cases} 0, & \text{if } n = 0 \\ 1, & \text{if } n = 1 \\ F(n-2) + F(n-1), & \text{if } n \ge 2 \end{cases}\]</p>
<p>You are given a number \(N\) \((1 \le N \le 10^{100\,000})\), find the \(N^{th}\) Fibonacci numbe...CCO '18 P5 - Boring Lectures (Online Version)2018-06-01T16:33:12+00:002018-06-01T16:33:12+00:00https://dmoj.ca/problem/cco18p5online<div><p><strong>Note: This problem is an online version of the <a href="https://dmoj.ca/problem/cco18p5">original version</a> held in CCO. Differences in the problem statement will be bolded. Note that the specifics of this problem are not set in stone, so constraints/limits/test data may change without notice. Feel free to submit strong test data for this problem if non-intended solutions AC.</strong></p>
<h5>Canadian Computing Olympiad: 2018 Day 2, Problem 2</h5>
<p>You have a schedule of \(N\...APIO '13 P1 - Robots2018-05-28T18:36:35+00:002018-05-28T18:36:35+00:00https://dmoj.ca/problem/apio13p1<div><p>The engineers at VRI (Voltron Robotics Institute) have built a swarm of \(n\) robots. Any two compatible robots that stands on the same grid can merge to form another composite robot.</p>
<p>We label the robots with number \(1\) to \(n\) \((n ≤ 9)\). Two robots are compatible if they have labels that are consecutive. Originally, each of the n robot has one unique label. A composite robot that is formed after merging two or more robots is assigned two labels, consisting of the minimum and...CCO '18 P6 - Flop Sorting2018-05-20T01:17:24+00:002018-05-20T01:17:24+00:00https://dmoj.ca/problem/cco18p6<div><h5>Canadian Computing Olympiad: 2018 Day 2, Problem 3</h5>
<p>Desperate to contribute to the CCO, Robert tried inventing a segment tree problem. The specification for that problem is:</p>
<blockquote><p>You are given a list of \(N\) distinct integers between \(1\) and \(N\). These are arranged in a row such that the \(i\)-th integer from the left is \(a_i\) , where \(1 \leq i \leq N\). We define a flop operation on a set of elements as swapping the minimum element of the set with the maxim...CCO '18 P5 - Boring Lectures2018-05-20T00:21:07+00:002018-05-20T00:21:07+00:00https://dmoj.ca/problem/cco18p5<div><h5>Canadian Computing Olympiad: 2018 Day 2, Problem 2</h5>
<p>You have a schedule of \(N\) upcoming lectures that you have the option of attending. The lectures are numbered from \(1\) to \(N\) and are in chronological order. From the current schedule, you expect that the \(i^{th}\) lecture will have quality \(a_i\). Since most of the lectures will be boring, you are only willing to attend some group of \(K\) consecutive lectures. You will skip the remaining lectures so that you can catch ...CCO '18 P4 - Gradient Descent2018-05-20T00:17:45+00:002018-05-20T00:17:45+00:00https://dmoj.ca/problem/cco18p4<div><h5>Canadian Computing Olympiad: 2018 Day 2, Problem 1</h5>
<p>Troy wants to play the following game with you.</p>
<p>He has a grid with \(R\) rows and \(C\) columns. Rows are numbered from \(1\) to \(R\) and columns are numbered from \(1\) to \(C\). Let the cell at row \(p\) and column \(q\) be denoted as \((p, q)\).</p>
<p>There are \(N\) tokens numbered from \(1\) to \(N\). Token \(i\) is placed at \((X_i, Y_i)\) where \(1\leq X_i\leq R\) and \(1\leq Y_i \leq C\). There may be multiple t...CCO '18 P3 - Fun Palace2018-05-20T00:08:13+00:002018-05-20T00:08:13+00:00https://dmoj.ca/problem/cco18p3<div><h5>Canadian Computing Olympiad: 2018 Day 1, Problem 3</h5>
<p>You are working hard to prepare a fun party for your fun friends. Fortunately, you have just located the perfect venue for your fun party: a <em>fun palace</em>. The fun palace has \(N\) <em>fun rooms</em> connected in a linear structure. The fun rooms are numbered from \(1\) to \(N\), and for \(1\leq i\leq N-1\), fun rooms \(i\) and \(i+1\) are connected by a <em>fun tunnel</em>. We say that such a fun tunnel is <em>incident</e...CCO '18 P2 - Wrong Answer2018-05-20T00:07:08+00:002018-05-20T00:07:08+00:00https://dmoj.ca/problem/cco18p2<div><h5>Canadian Computing Olympiad: 2018 Day 1, Problem 2</h5>
<p>Troy made the following problem (titled WA) for a programming contest:</p>
<blockquote><p>There is a game with \(N\) levels numbered from \(1\) to \(N\). There are two characters, both are initially at level 1. For \(i<j\), it costs \(A_{i,j}\) coins to move a character from level \(i\) to level \(j\). It is not allowed to move a character from level \(i\) to level \(j\) if \(i>j\). To win the game, every level (except lev...CCO '18 P1 - Geese vs. Hawks2018-05-20T00:06:59+00:002018-05-20T00:06:59+00:00https://dmoj.ca/problem/cco18p1<div><h5>Canadian Computing Olympiad: 2018 Day 1, Problem 1</h5>
<p>Troy and JP are big hockey fans. Every hockey team played \(N\) games this season. Each game was between two teams and the team that scored more points won. No game ended in a tie.</p>
<p>Troy's favourite team is the Waterloo Geese and he recorded the outcome of all their games as a string \(S\). \(S_i=\)<code>W</code> if the Geese won their \(i\)-th game; otherwise \(S_i=\)<code>L</code> if the Geese lost their \(i\)-th game. H...ECOO '18 R2 P1 - Artificial Photosynthesystem2018-05-12T23:47:08+00:002018-05-12T23:47:08+00:00https://dmoj.ca/problem/ecoo18r2p1<div><p>The technology world is currently working on a way to generate oxygen so that we can combat the effects of climate change. One of the ways that this is being done is through the creation of an artificial photosynthesystem.</p>
<p>the basic idea behind the process is that you need an artificial "leaf" and an artificial "fish" submerged into a vat of carbonated sugar water, which consists of sugar (\(S\)), water (\(W\)), oxygen (\(O\)), and carbon dioxide (\(C\)). The leaf is capable of ph...ECOO '18 R2 P2 - Homework2018-05-12T23:42:11+00:002018-05-12T23:42:11+00:00https://dmoj.ca/problem/ecoo18r2p2<div><p>George has procrastinated too much on his \(N\) homework assignments, and now he is running out of time to finish them all.</p>
<p>Each of George's \(N\) assignments has a weight that it contributes to his grade and a deadline in days from today. George will need one day to finish any of the assignments and he must complete an assignment before its deadline in order to submit it (he can't complete it the day an assignment is due).</p>
<p>Help George figure out the order in which he shoul...