Recently Added WLMOJ Problemshttps://judge.mcpt.ca/2019-01-26T21:26:40+00:00The latest problems added on the William Lyon Mackenzie Online Judge websiteCounting Lines2019-01-26T21:26:40+00:002019-01-26T21:26:40+00:00https://judge.mcpt.ca/problem/countinglines<p>Theodore is writing code! He wants to count how many lines of code he has, but doesn't know how to.</p>
<p>Can you help him count?</p>
<h4>Input Specification</h4>
<p>An unknown number of lines of code.</p>
<h4>Output specification</h4>
<p>The number of lines of code that Theodore has written.</p>
<h4>Sample Input</h4>
<pre><code>uint64_t
getArgID(char const * target_arg)
{
if (strlen(target_arg) == 2) if (target_arg[0] == '-')
switch (target_arg[1])
{
case 'i...A Counting Problem 22019-01-17T00:39:48+00:002019-01-17T00:39:48+00:00https://judge.mcpt.ca/problem/acountingproblem2<p>You are given a digit array \(a\) of length \(N\). You must find the number of integers between \(0\) and \(K\) (inclusive) satisfying the following condition, modulo \(10^9 + 7\):</p>
<ul>
<li>The digits \(a_i\) for all \(i\ (1 \le i \le N)\) show up at least once in the integer.</li>
</ul>
<h4>Input Specification</h4>
<p>The first line will contain the integer \(N\ (1 \le N \le 10)\).</p>
<p>The next line will contain \(N\) integers, \(a_i\ (0 \le a_i \le 9)\). It is guaranteed \(a_i\) is d...Graph Theory 42019-01-17T00:39:48+00:002019-01-17T00:39:48+00:00https://judge.mcpt.ca/problem/graphtheory4<p>Given a directed graph of \(N\) nodes, \(M\) edges, a node \(A\), and a node \(B\), print <code>YES</code> if it is possible to travel from \(A\) to \(B\) even if any one edge is removed from the graph, and <code>NO</code> otherwise. If it is impossible to travel from \(A\) to \(B\), print <code>NO PATH</code>.</p>
<h4>Input Specification</h4>
<p>The first line will contain four integers, \(N, M, A, B\ (2 \le N \le 4 \times 10^4, 1 \le M \le 10^5, 1 \le A, B \le N, A \neq B)\).</p>
<p>The nex...A Two-Pointers Problem 22019-01-17T00:39:48+00:002019-01-17T00:39:48+00:00https://judge.mcpt.ca/problem/apointerproblem2<p>Given an array \(a\) of \(N\) integers, find the shortest length subarray that has a sum greater than or equal to \(M\).</p>
<h4>Input Specification</h4>
<p>The first line will contain \(2\) integers, \(N, M\ (1 \le N \le 10^5, 1 \le M \le 10^9)\).</p>
<p>The second line will contain \(N\) integers \(a_1, a_2, \ldots, a_N\ (|a_i| \le 10^7)\).</p>
<h4>Output Specification</h4>
<p>Output the shortest length subarray that has a sum greater than or equal to \(M\). If there is no subarray, print <...An AQT Problem2019-01-17T00:39:48+00:002019-01-17T00:39:48+00:00https://judge.mcpt.ca/problem/anaqtproblem<p>AQT is trying to get better at programming. However, he can't, despite his best efforts, and as such has resorted to copying code. He wishes to copy code from coder \(a_N\). Little does he know, code \(a_N\) copies from coder \(a_{a_N}\). In fact, coder \(a_{a_N}\) also copies code from code \(a_{a_{a_N}}\). This continues to form a tree, up until coder \(1\), who writes his own code. AQT is a leaf node, that is, no one copies code from him. There are many other leaf nodes, such as BQT, and C...A Max Problem2019-01-17T00:39:48+00:002019-01-17T00:39:48+00:00https://judge.mcpt.ca/problem/amaxproblem<p>Max loves to maximize elements. As such, he gives you an array \(a\) of length \(N\), and wants you to print the maximum product of any \(2\) elements in the array! Note that the two elements <strong>could both be</strong> the same element.</p>
<h4>Input Specification</h4>
<p>The first line will contain the integer \(N\ (1 \le N \le 100)\).</p>
<p>The next line will contain \(N\) integers, \(a_1, a_2, \ldots, a_N\ (|a_i| \le 10^9)\).</p>
<h4>Output Specification</h4>
<p>Output the maximum pro...Inaho XI2019-01-13T19:34:48+00:002019-01-13T19:34:48+00:00https://judge.mcpt.ca/problem/inaho11<p>Given \(M\) points in \(N\) dimensional space, find the minimum "surface area" of a hyperrectangle required to contain all \(M\) points modulo \(10^9+7\).</p>
<p>As an example, the "surface area" of a \(2\)-dimensional hyperrectangle (rectangle) is the sum of its \(4\) side lengths. The "surface area" of a \(3\)-dimensional hyperrectangle (rectangular prism) is the sum of the areas of the \(6\) sides of the hyperrectangle.</p>
<h4>Input Specification</h4>
<p>The first line will contain two sp...Inaho X2019-01-13T19:34:18+00:002019-01-13T19:34:18+00:00https://judge.mcpt.ca/problem/inaho10<p>Inaho is given an array \(k\) of length \(N\), such that \(k_i\) is a <strong>unique</strong> integer. With the array, he defines a function:</p>
<p>\[f(x) = \displaystyle \sum_{i=1}^{N}{\sin{(2^{k_i} x)}}\]</p>
<p>Inaho wants to play a game with you! He wants you to recreate the array. Because he knows this is impossible, he will allow you to ask him some questions. In particular, you are to ask him \(x\), where \(0 \le x \le \pi\), and he will reply with \(f(x)\). He wants this to be challe...Inaho IX2019-01-13T19:33:42+00:002019-01-13T19:33:42+00:00https://judge.mcpt.ca/problem/inaho9<p>Inaho is given a function:</p>
<p>\[
f(x) = \begin{cases} a_1f(x-1) + a_2f(x-2) + \ldots + a_Nf(x-N) & \text{if } x > N \\ 1 & \text{if } x \le N \end{cases}
\]</p>
<p>Given \(N, Z\) and \(a\), Inaho wants you to print \(f(Z) \bmod 10^9 + 7\).</p>
<h4>Input Specification</h4>
<p>The first line will contain two integers, \(N, Z\ (1 \le N \le 10, 1 \le Z < 10^{10\ 000})\).</p>
<p>The second line will contain \(N\) integers, \(a_1, a_2, \ldots, a_N\ (1 \le a_i \le 10^6)\).</p>
<h4>...Inaho VIII2019-01-13T19:31:12+00:002019-01-13T19:31:12+00:00https://judge.mcpt.ca/problem/inaho8<p>Inaho was thinking of a tree problem, when he came up with this rather beautiful problem!</p>
<p>Given a tree originally rooted at \(1\) containing \(N\) nodes each with a value \(v_i\) and an arbitrary value \(K\), support \(Q\) of following operations:</p>
<ul>
<li><code>1 R</code> Reroot the tree so that node \(R\) is the root.</li>
<li><code>2 a b</code> Print the highest common ancestor of nodes \(a\) and \(b\).</li>
<li><code>3 a b</code> Print the sum of all nodes' \(v_i\) on the path ...Inaho VII2019-01-13T19:30:08+00:002019-01-13T19:30:08+00:00https://judge.mcpt.ca/problem/inaho7<p>Inaho is finally home! After being stuck in an \(N\)-dimensional for so long, he has started to comprehend the complexities of \(N\) dimensions and have thought of a problem. Unfortunately, he does not know of a solution as he is not yet a master of \(N\) dimensions, so he has asked you for help.</p>
<p>Given an \(N\)-dimensional array, and a type of operation:</p>
<p>Type \(1\) operation: print the normal array given the Binary Indexed Tree.</p>
<p>Type \(2\) operation: print the Binary Inde...Inaho VI2019-01-13T18:59:56+00:002019-01-13T18:59:56+00:00https://judge.mcpt.ca/problem/inaho6<p>Inaho is very close to home! After leaving the \(N\)-dimensional hole through the first gate, he arrives at another gate. On this gate is a natural number and two floating-point combination locks. Between the first and second lock is a \(+\) sign, and next to the second lock is the letter \(i\). Strange. Extremely tired from travelling through the \(N\)-dimensional hole, Inaho asks you to tell him what to set each combination lock to. However, if you tell him the wrong answer, Inaho will be s...Inaho V2019-01-13T18:58:41+00:002019-01-13T18:58:41+00:00https://judge.mcpt.ca/problem/inaho5<p>Inaho has arrived at the gates to return to his petty \(3\)-dimensional world, but the gates are locked! He wants to get home as quickly as possible to continue playing his <em>Graph Simulater 2015</em>, that is within \(0.2\) seconds, but the gates are preventing him from leaving. On the gates are \(M\) nonpositive integers, and he believes finding the sum will allow him back into his \(3\)-dimensional world. Of course, he is still stuck in the \(N\)-dimensional hole, and therefore cannot co...Inaho IV2019-01-13T18:56:40+00:002019-01-13T18:56:40+00:00https://judge.mcpt.ca/problem/inaho4<p>Inaho has just realized he can travel diagonally, and also that density has nothing to do with how fast he can travel. He very much appreciates your help for trying to <a href="https://dmoj.ca/problem/inaho3" rel="nofollow">walk him through space</a>, but he no longer needs your instructions. He now only needs the direct distance from his current position to his destination. As he still cannot understand the complexities of \(N\)-dimensions, please help him (for the last time, we promise)!</p...Inaho III2019-01-13T18:53:06+00:002019-01-13T18:53:06+00:00https://judge.mcpt.ca/problem/inaho3<p>Now that Inaho knows the direction of the least density, he wants to get out of this horrible \(N\)-dimensional hole to return to playing his <em>Graph Simulator 2015</em>. Each unit of density costs him \(1\) year to walk through, and he wants to leave as quickly as possible. Of course, these are \(N\)-dimensional years we're talking about, which translates to \(1\) nanosecond in \(3\)-dimensional space. As he still cannot understand the complexities of \(N\) dimensions, he asks for your hel...Inaho II2019-01-13T18:42:41+00:002019-01-13T18:42:41+00:00https://judge.mcpt.ca/problem/inaho2<p>Inaho is a scientist. He discovered the fourth dimension recently. In fact, he also discovered the fifth, the sixth, the seventh, the eighth, the ninth, and the tenth dimension! Today, as he was travelling on the infinite plane of uniform density, he fell into an \(N\)-dimensional hole. "How did that even happen?" he asks himself in disbelief, but quickly realizing that finding his way out is perhaps more important. However, as a measly \(3\)-dimensional being, he cannot understand the comple...An FFT Problem VI2019-01-12T22:30:26+00:002019-01-12T22:30:26+00:00https://judge.mcpt.ca/problem/fft6<h4>Statement</h4>
<p>Alice and Bob have huge dice where the possible roll values are from \(0\) to \(N\) (inclusive).</p>
<p>These huge dice have many many faces. In particular, Alice's die has \(A_i\) faces with roll value \(i\), while Bob's die has \(B_j\) faces with roll value \(j\).</p>
<p>Alice and Bob roll their dice at the same time. Their score is the sum of their roll values. Alice and Bob are wondering: for each of the possible scores \(s\) from \(0\) to \(2N\) (inclusive), how many d...LCC '18 Contest 4 S5 - Durak2019-01-11T02:05:49+00:002019-01-11T02:05:49+00:00https://judge.mcpt.ca/problem/lcc18c4s5<p>Durak (translation: fool) is a Russian card game commonly played by two players who take turns attacking each other. Each player has a hand of \(N\) cards, and an attack happens as follows:</p>
<ul>
<li>The attacking player plays some card from his hand</li>
<li>The defending player then needs to beat that card by playing a card of the same suit and higher rank, or a trump card (see note below).</li>
<li>The attacking player can then continue the attack by playing a card that has the same ran...LCC '18 Contest 4 S4 - Car Range2019-01-11T02:05:49+00:002019-01-11T02:05:49+00:00https://judge.mcpt.ca/problem/lcc18c4s4<p>Elon is looking into buying an electric car, however he is worried that it will affect his ability to go on long road trips. In particular, he is planning a road trip from Toronto to Vancouver this summer and he will need a car that can take him all the way there.</p>
<p>There are \(N\) cities with electric charging stations in North America and \(M\) roads between them. Elon can use a road only if it is shorter than the range of his electric vehicle. What is the minimum range that Elonâ€™s veh...LCC '18 Contest 4 S3 - Flight Plan2019-01-11T02:05:49+00:002019-01-11T02:05:49+00:00https://judge.mcpt.ca/problem/lcc18c4s3<p>Howard has recently started a new full-time job which gives him \(K\) vacation days to use during the year. He is looking to spend all of his vacation days on a single trip to Hanoi, however he is having a hard time finding a pair of flights that are exactly \(K\) days apart.</p>
<p>Given the \(N\) flights to and from Hanoi this year, find the minimum cost of two flights \(A\) and \(B\) such that:</p>
<ul>
<li>\(A\) is a flight to Hanoi.</li>
<li>\(B\) is a flight from Hanoi.</li>
<li>\(A\) a...LCC '18 Contest 4 S2 - VInts2019-01-11T02:05:49+00:002019-01-11T02:05:49+00:00https://judge.mcpt.ca/problem/lcc18c4s2<p>A VInt (Variable Integer) is an integer encoding that allows one to store non-negative integers of variable length. A VInt is stored as a sequence of bytes where each byte is of the following format:
The first bit of each byte is <code>0</code> if this is the last byte of the VInt, or <code>1</code> otherwise.
The remaining seven bytes contain part of the binary representation of the VInt.</p>
<p>So for example, the binary number:</p>
<center> \(01010010001000\) </center><p>Can be represented...LCC '18 Contest 4 S1 - Damage Calculation2019-01-11T02:05:49+00:002019-01-11T02:05:49+00:00https://judge.mcpt.ca/problem/lcc18c4s1<p>Catarina loves playing ARPGs, specifically Diablo-style games, and spent all of Winter break playing them. One thing in common with a lot of these games is their item system: each item has at most \(6\) damage modifiers (mods), each of which is one of three types:</p>
<ul>
<li><code>X added damage</code>: this mod adds a flat amount of damage.</li>
<li><code>Y increased damage</code>: this mod increases the base damage by \(Y\%\).</li>
<li><code>Z more damage</code>: this mod increases the to...LCC '18 Contest 4 J2 - Dereck and Essays2019-01-11T02:05:49+00:002019-01-11T02:05:49+00:00https://judge.mcpt.ca/problem/lcc18c4j2<p>Dereck is infuriated with his English teacher because she said that the Earth is round. To get back at her, he has decided to take sentences from his essay and reverse the order of the characters in every word (words are separated by only one space).</p>
<h4>Input Specification</h4>
<p>The first line will contain one string, \(S\ (1 \le |S| \le 2000)\), consisting of English letters and punctuation.</p>
<h4>Output Specification</h4>
<p>On the first line, output \(S\) with the order of the cha...LCC '18 Contest 4 J3 - Minecraft Construction Contractor2019-01-11T02:05:49+00:002019-01-11T02:05:49+00:00https://judge.mcpt.ca/problem/lcc18c4j3<p>Junyi is a Minecraft home designer, who is widely sought after for his straightforward rectangular designs. To construct a house, he builds a rectangular room with \(4\) walls and \(1\) roof. Additionally, to construct all his houses, he uses diamond blocks, which are crafted using \(9\) diamonds. When Junyi mines, he finds diamonds at a rate of \(32\) per hour. He only mines for full hours at a time, so he will sometimes return with extra diamonds.</p>
<p>Given the house dimensions a custome...LCC '18 Contest 4 J1 - Terminus Quest2019-01-11T02:05:49+00:002019-01-11T02:05:49+00:00https://judge.mcpt.ca/problem/lcc18c4j1<p>On his quest to solve <a href="https://dmoj.ca/problem/stnbd6" rel="nofollow">Terminus Est</a>, Max finds an ancient scroll that claims to be the key to solving the problem.</p>
<p>The scroll proclaims:</p>
<blockquote><p>The one to solve Terminus Est shall be able to recognize patterns.</p>
</blockquote>
<p>Max interprets this as the ability to recognize arithmetic patterns.</p>
<p>Max defines an arithmetic pattern as a list (\(a\)) of \(N\) integers where the difference between any adjacent...