Recently Added MCPT Problemshttps://mcpt.ca/2020-03-14T14:27:29.985614+00:00The latest problems added on the MCPT's Online Judge websiteLCC/Moose '19 Contest 5 S5 - Caterpillar2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5s5<div><p>For some integers \(N, K, M\), define the "caterpillar sum" to be the following sum:</p>
<p>\[ \mathrm{Caterpillar}(N, K, M) = \sum_{x=K \times M}^N x(x-M)(x-2M)...(x-(K-1)M) \]</p>
<p>For example, the caterpillar sum for \(N = 5, K = 3, M = 1\) is \(3\times 2\times 1 + 4\times 3\times 2 + 5\times 4\times 3 = 90\).</p>
<p>Your task is to evaluate the caterpillar sum for various values of \(N, K\), and \(M\).</p>
<h4>Input Specification</h4>
<p>The input begins with an integer \(T\) \((1 ...LCC/Moose '19 Contest 5 S4 - Manhattan2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5s4<div><p>Reyno has recently moved to New York and is looking for housing in Manhattan. He wants to use this opportunity to introduce some healthy habits to his life, particularly going to the gym and cooking at home. To make this goal easier to achieve, he'd like to find a housing location that's as close as possible to both a grocery store and a gym.</p>
<p>Manhattan has \(N\) gyms and \(M\) grocery stores, each located at some intersection of a street \(Y\) (which go horizontally) and avenue \(...LCC/Moose '19 Contest 5 S3 - Futures2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5s3<div><p>Tim has discovered a time machine! Tim has read enough about time travel to know that he should not do any wacky things, so he decides to be boring and serious: he will get future stock prices using the machine, then trade the stock using that information. However, he needs to be careful: if he makes more than \(K\) trades in a day or has more than one active trade at a time, then he is at risk of impacting the future or being found out.</p>
<p>As Tim's co-founder, you're in charge of fi...LCC/Moose '19 Contest 5 S1 - Genome2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5s1<div><p>As part of the global effort to combat COVID-19, scientists are sequencing the genome of many samples that they find. Using this information, it is possible to trace how the virus evolves and how it spread, as well as helps in finding a cure.</p>
<p>As a simple model, the virus's genome can be represented by a string consisting of the letters <code>A</code>, <code>T</code>, <code>C</code>, <code>G</code>. The difference between two strains \(X\) and \(Y\) is equal to the number of positi...LCC/Moose '19 Contest 5 J1 - Catastrophic Charger2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5j1<div><p>Everyone has trouble plugging in things into their computers, especially USB's. However, in this case, Alice has a charger that can only be plugged in a specific way. Her charger can only be plugged in in one direction, or else in any other case it will say that the computer is not charging. Given the degrees that the charger needs to be plugged in to charge, and \(N\) different degrees that Alice wants to plug her charger in, determine for each degree if her laptop is able to charge or ...LCC/Moose '19 Contest 5 J2 - Cereal2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5j2<div><p>Bob and Steve the cows are eating cereal for breakfast. Being very hungry, Bob decides to steal Steve's cereal while he is looking away. Bob takes a total of one second to check if Steve has a piece of cereal at a certain position and take it if there is. Not wanting to waste his time, he will only check Steve's bowl if he does not already have a piece of cereal in that position. So, if he has a piece of cereal in his bowl, he will move onto the next position, taking no time. He can also...LCC/Moose '19 Contest 5 J5 - 4D Strings2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5j5<div><p>A string is considered a <em>palindrome</em> if it is the same forwards as it is backwards. For example, <code>aa</code> and <code>racecar</code> are palindromes, while <code>abaa</code> and <code>hello</code> are not.</p>
<p>A string \(s\) considers a string \(t\) a <em>friend</em> if the concatenation of \(s\) and \(t\) \((s + t)\) <strong>in that order</strong> results in a <em>palindrome</em>.</p>
<p>In addition, two strings \(s\) and \(t\) are <em>close</em> iff <strong>both</strong...LCC/Moose '19 Contest 4 J4 - Inaho's Walk2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5j4<div><p>Inaho is taking a walk! He texts you the location he walks to from his house, which is located at the origin \((0, 0)\) on a 2D plane. You know that the location has coordinates \((x, y)\). However, Inaho can only walk in 2 directions: \(v\) and \(w\).</p>
<p>\(v\) is defined as the direction from \((0, 0)\) to \((v_x, v_y)\), and Inaho defines that distance as 1 \(V\).</p>
<p>\(w\) is defined as the direction from \((0, 0)\) to \((w_x, w_y)\), and Inaho defines that distance as 1 \(W\)....LCC/Moose '19 Contest 5 S2 - Bad Blockchain2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5s2<div><p>The Sketchy Government Spying Organization (SGSO) has released a new blockchain, but you're skeptical of its security. To show that it's insecure, you need to be able to quickly solve the proof-of-work problem on your weak computer.</p>
<p>The proof-of-work problem is:</p>
<blockquote><p>Given an integer \(N\), followed by \(N\) integers in the range \([0, 100\,000]\) (each on its own line), output the \(N\) integers in ascending order.</p>
</blockquote>
<h4>Input Specification</h4>
<p>T...LCC/Moose '19 Contest 4 J3 - Speedcubing2020-03-14T14:27:29.985614+00:002020-03-14T14:27:29.985614+00:00https://mcpt.ca/problem/lcc19c5j3<div><p>Derek is at his first speedcubing competition, and he is participating in the "3x3 Average of Five" event. He has to solve the Rubik's cube \(5\) times, and his average time is the <em>mean</em> of the middle \(3\) times. <strong>This means the average excludes his best and worst solve times</strong>. There are \(N\) competitors at the event, including Derek. Can you figure out what place Derek is? Placement is determined as the number of competitor with an average solve time strictly le...Irreducible Root2020-03-06T04:26:20+00:002020-03-06T04:26:20+00:00https://mcpt.ca/problem/irrootducible<div><p>Given an array \(a\) with length \(N\) of positive integers, find the amount of unordered pairs of indices \(i,j\ i \neq j\) there are such that \(a_i\cdot a_j\) is an irreducible \(K^{th}\) root.</p>
<p>A \(K^{th}\) root is reducible if it has a \(K^{th}\) power other than 1 as a factor.</p>
<h4>Input Specification</h4>
<p>The first line will contain two integers, \(N\ (1 \leq N \leq 10^5)\), and \(K\ (2 \leq K \leq 30)\).</p>
<p>The next line will contain \(N\) integers, the array \(a\...Speedwriting2020-02-28T21:40:37+00:002020-02-28T21:40:37+00:00https://mcpt.ca/problem/speed<div><p>So [user:nicoella] and [user:AlanL] got put together to create a problem. <del>Since [user:AlanL] actually has a proper sleep schedule and doesn't sleep at 3 am</del> Since [user:AlanL] likes to sleep, he sleeps earlier than [user:nicoella] does. However, this gives [user:nicoella] less time to discuss about the problem! And since they have to get the problem finished, she is debating whether she should start writing the problem, or wait for him to wake up to create his own idea to write...Unique Subsets2020-02-28T21:39:39+00:002020-02-28T21:39:39+00:00https://mcpt.ca/problem/uniquesubset<div><p>Given an array of \(N\) integers, print the number of different subsets such that no two subsets have identical contents, and that every subset does not contain duplicate elements. Since this number can be very large, print it modulo \(10^9+7\). Note that the empty subset is counted.</p>
<h4>Input Specification</h4>
<p>The first line will contain the integer \(N\ (1 \le N \le 10^5)\), the number of integers.</p>
<p>The next line will contain \(N\) integers \(a_i\ (1 \le a_i \le 10^9)\), ...Pop Quiz!2020-02-17T18:29:17+00:002020-02-17T18:29:17+00:00https://mcpt.ca/problem/popquiz<div><p>Suddenly, a wild Derek emerges from the shadows and surprises a student with a pop quiz! Derek asks the student \(N\) multiplication questions, and if the student gets all the questions right, Derek awards the student with a whole chocolate bunny.</p>
<h4>Input Specification</h4>
<p>The first line of input contains one integer, \(N\), the number questions Mateo asked</p>
<p>The next \(N\) lines contain three integers \(A\), \(B\) and \(P\), being the multiplicand, multiplier and the stud...A Loop Problem2020-02-17T18:28:17+00:002020-02-17T18:28:17+00:00https://mcpt.ca/problem/aloopproblem<div><p>Dereck is learning for loops but doesn't know what a keyboard is. Can you help him?</p>
<p>Given \(L\) and \(R\), output the sum of all integer numbers between \(L\) and \(R\) (inclusive).</p>
<h4>Input Specification</h4>
<p>The first line will contain the integers \(L\) and \(R\) (\(0\ <\ L\ \le\ R\ \le\ 2^{31}-1\)).</p>
<h4>Output Specification</h4>
<p>Output the sum of all integer numbers between \(L\) and \(R\) (inclusive).</p>
<h4>Sample Input</h4>
<pre><code>1 10</code></pre>
<...Mock CCC '20 Contest 1 S1 - Arithmetic Hybercube2020-02-12T14:26:17.464672+00:002020-02-12T14:26:17.464672+00:00https://mcpt.ca/problem/mccc20c1s1<div><p>Arithmetic Square, everyone's favourite problem. Welcome to the better problem, Arithmetic Line!</p>
<p>You are given \(N\) integers, which are guaranteed to form an arithmetic sequence. However, they appear scrambled! Can you recreate the arithmetic sequence given the \(N\) integers?</p>
<p>Recall that an arithmetic sequence of length \(N\) is a sequence of integers of the form</p>
<p>\[ a, a+d, a+2d, \ldots, a+(N-1)d \]</p>
<p>for integer values of \(a\) and \(d\). <strong>For the purp...Mock CCC '20 Contest 1 S2 - 4D BBST on a DP2020-02-12T14:26:17.464672+00:002020-02-12T14:26:17.464672+00:00https://mcpt.ca/problem/mccc20c1s2<div><p>You happened to find a queue of \(N\) lowercase latin characters in the mailbox. You decide you want to do something productive with these characters. As such, you will try to build a string. For each character in the queue, in order, you will either prepend or append the character to a new string, and then remove the character from the queue. Recall that a queue is First-In First-Out (FIFO), meaning that the character at the front of the queue (the first character) is removed first, sec...Mock CCC '20 Contest 1 S3 - Tree Programming2020-02-12T14:26:17.464672+00:002020-02-12T14:26:17.464672+00:00https://mcpt.ca/problem/mccc20c1s3<div><p>A tree is a strange type of graph. We will not be dealing with trees today, as they are too hard.</p>
<p>You are instead given a graph of \(N\) nodes and \(M\) edges. Edge \(i\) connects nodes \(u_i\) and \(v_i\) with a value of \(k_i\). A path from \(a_j\) to \(b_j\) consists of a sequence of the \(M\) edges, such that consecutive edges in the path share a common node. The <em>value</em> of this path is the bitwise OR of all the edge values in the path.</p>
<p>Given \(Q\) queries, \(a_j...Mock CCC '20 Contest 1 S5 - Sticks2020-02-12T14:26:17.464672+00:002020-02-12T14:26:17.464672+00:00https://mcpt.ca/problem/mccc20c1s5<div><p>You have \(A\) sticks each of length \(a\) metres and \(B\) sticks each of length \(b\) metres which you are trying to place into one of \(M\) tubes. Tube \(i\) has a length of \(l_i\) metres. Each tube can fit some number of sticks such that sum of the length of the sticks do not exceed \(l_i\). Each stick can also only go in at most one tube. What is the maximum number of sticks that can be put into the tubes?</p>
<h4>Input Specification</h4>
<p>The first line will contain two integers...Mock CCC '20 Contest 1 J5 - A Trivial Problem2020-02-12T14:26:17.464672+00:002020-02-12T14:26:17.464672+00:00https://mcpt.ca/problem/mccc20c1j5<div><p>You are given an array \(a\) of \(2N\) integers. Can you arrange the elements in such a way as to <strong>maximize</strong> \(S = \displaystyle \sum_{i=1}^N |a_i - a_{i+N}|\)?</p>
<h4>Input Specification</h4>
<p>The first line will contain the integer \(N\) \((1 \le N \le 10^5)\).</p>
<p>The second line will contain \(2N\) integers, \(a_1, a_2, \ldots, a_{2N}\) \((1 \le a_i \le 10^9)\).</p>
<h4>Output Specification</h4>
<p>Output the maximum value of \(S\).</p>
<h4>Subtasks</h4>
<p>For 4...Mock CCC '20 Contest 1 J4 - Immobile Phones2020-02-12T14:26:17.464672+00:002020-02-12T14:26:17.464672+00:00https://mcpt.ca/problem/mccc20c1j4<div><p>There are \(N\) phones numbered from \(1\) to \(N\) lined up in a row. The \(i^\text{th}\) phone is a distance of \(i\) kilometres away from the cell tower. Each phone is communicating with the tower on a frequency of \(f_i\).</p>
<p>Some phones will intefere if with another phone if they are on the same frequency. In particular, a phone's signal will not get through to the cell tower if there is a phone closer communicating at the same frequency.</p>
<p>Given a row of phones, can you de...Mock CCC '20 Contest 1 J2 - Tie2020-02-12T14:26:17.464672+00:002020-02-12T14:26:17.464672+00:00https://mcpt.ca/problem/mccc20c1j2<div><p>A tie in a game occurs when you have an equal number of wins as losses.</p>
<p>Given a series of wins and losses, can you determine if there is a tie or not?</p>
<h4>Input Specification</h4>
<p>The first line will contain the integer \(N\), the number of events that occur. There will be between \(1\) and \(100\) events, inclusive.</p>
<p>The next \(N\) lines will each contain an integer, \(d\), followed by either <code>L</code> or <code>W</code>. This means that you lost or won \(d\) tim...Mock CCC '20 Contest 1 J3 - Win2020-02-12T14:26:17.464672+00:002020-02-12T14:26:17.464672+00:00https://mcpt.ca/problem/mccc20c1j3<div><p>Given a string containing lowercase latin characters, can you split the string by a character?</p>
<h4>Input Specification</h4>
<p>The first line will contain the string \(S\). The length of \(S\) is between \(1\) and \(1000\) characters, inclusive. \(S\) will only contain lowercase latin characters.</p>
<p>The second line will contain a character \(c\). \(c\) is a lowercase latin character.</p>
<h4>Output Specification</h4>
<p>Split the string \(S\) by \(c\), and output each resultant s...Mock CCC '20 Contest 1 J1 - Loss2020-02-12T14:26:17.464672+00:002020-02-12T14:26:17.464672+00:00https://mcpt.ca/problem/mccc20c1j1<div><p>Chris has a number of $1, $5, $10, and $20 bills in his pocket. Nayaab also has a number of $1, $5, $10, and $20 bills in her pocket. Can you determine who has more money?</p>
<h4>Input Specification</h4>
<ul>
<li>The first line will contain the number of $1 bills <strong>Chris</strong> has.</li>
<li>The second line will contain the number of $5 bills <strong>Chris</strong> has.</li>
<li>The third line will contain the number of $10 bills <strong>Chris</strong> has.</li>
<li>The fourth l...Mock CCC '20 Contest 1 S4 - Rotational Arrays2020-02-12T14:26:17+00:002020-02-12T14:26:17+00:00https://mcpt.ca/problem/mccc20c1s4<div><p>An array \(a\) of \(N\) elements can be rotated to the right by taking the last element and moving it to the front. For example, rotating \([1, 2, 3, 4]\) to the right once results in \([4, 1, 2, 3]\).</p>
<p>An array is considered <em>rotational</em> if it can be rotated some number of times \(k\) to the right, where \(1 \le k \lt N\), and result in the original array. For example, the array \([1, 1, 1]\) is considered <em>rotational</em>.</p>
<p>One <em>modification</em> of an array co...