Recently Added TSSOJ Problemshttps://tssoj.ca/2021-03-06T19:36:37+00:00The latest problems added on the Thornhill Secondary School Online Judge websiteTSSPC '20 Contest 1 P5 - Trick or Trail2021-03-06T19:36:37+00:002021-03-06T19:36:37+00:00https://tssoj.ca/problem/tsspc20c1p5<p>It's Halloween and [user:Henry_Zhang] loves candy, but is too scared to go trick or treating (he's very afraid). He lives in a terrifying grid neighbourhood of dimension \(n\) x \(m\). [user:sankeeth_ganeswaran] lives at \((0,0)\) and he wants to deliver candy to [user:Henry_Zhang] who lives at \((n,m)\). [user:sankeeth_ganeswaran] rides his old haunted broomstick but accidentally trips and squishes it, breaking it under all his weight! His broken broom can only fly him up or right on the gri...IO Benchmark2021-03-06T16:58:10+00:002021-03-06T16:58:10+00:00https://tssoj.ca/problem/iotest<p>Test your fast input template!</p>
<h5>Note: It is not guaranteed that all languages can pass.</h5>
<h4>Input Specification</h4>
<p>The first line will contain an integer \(N\).</p>
<p>The next line will contain \(a\), a sequence of \(N\) space-separated integers.</p>
<h4>Output Specification</h4>
<p>For each integer \(a_i\), output on a new line the value of \(a_i + 1\)</p>
<h4>Constraints</h4>
<p>For all subtasks:</p>
<p>\(1 \le N \le 5\,000\,000\)</p>
<p>\(1 \le a_i \le 10^9\)</p>
<h5>Subt...Hashbrown2021-03-06T16:57:56+00:002021-03-06T16:57:56+00:00https://tssoj.ca/problem/hashbrown<p>Adam loves hashbrowns, specifically, hashbrowns that his factory produces. So, he asked you to pay a visit to his factory and count the number of <em>favorite</em> hashbrowns on a conveyor belt of \(N\) numbers. His favorite hashbrown is defined as a series of \(M\) numbers. On the conveyor belt, you must count all contiguous subarrays that exactly matches the hashbrown.</p>
<h4>Input Specification</h4>
<p>The first line contains: \(N\) and \(M\) \((1 \le M \le N \le 500\,000)\), representing...A Very Coordinated Christmas2021-03-06T16:57:46+00:002021-03-06T16:57:46+00:00https://tssoj.ca/problem/xmascoordinates<p>It's Christmas! But unfortunately, Santa's sleigh stopped working! So he has asked Encodeous to help deliver his presents. Santa gave him an \(N\) by \(M\) grid to show where to deliver them. Santa told him that he must travel to a specified destination while picking up a present along the way. To pick it up, he must stand exactly over the location of the present.</p>
<p>Santa's grid will contain the following characters:</p>
<ul>
<li><code>#</code> representing a wall that he cannot travel t...Yesn't2021-03-06T16:57:28+00:002021-03-06T16:57:28+00:00https://tssoj.ca/problem/yesnt<p>While surfing the internet, Dahyun has discovered a brand new word.</p>
<p>The word <code>yesnt</code> has the <a href="https://www.urbandictionary.com/define.php?term=Yesn%27t" rel="nofollow">meaning</a> of <code>no</code>. Similarly, <code>nont</code> has the meaning of <code>yes</code>.</p>
<p>When the suffix <code>nt</code> is added multiple times, the meaning of the words alternate between <code>yes</code> and <code>no</code>.</p>
<p>For example, the word <code>yesntnt</code> has the mea...TSSPC '20 Contest 1 P4 - Halloween Spooking2021-03-06T16:56:44+00:002021-03-06T16:56:44+00:00https://tssoj.ca/problem/tsspc20c1p4<p>It's Halloween again! Little [user:sankeeth_ganeswaran] goes scaring people in his neighbourhood. Each neighbour he visits has a certain amount of Trehalose (noise tolerance). Some neighbours are easily scared and some are quite fearless! This is very sad for [user:sankeeth_ganeswaran] whose voice can only scream \(M\) Trehalose. There are \(N\) houses numbered \(1\) to \(N\). Each house \(h_i\) has a Trehalose tolerance of \(m_i\). Output the largest range of houses [user:sankeeth_ganeswaran...TSSPC '20 Contest 1 P3 - Candy Machine2021-03-06T16:56:36+00:002021-03-06T16:56:36+00:00https://tssoj.ca/problem/tsspc20c1p3<p>After going out to trick or treat, Adam's plan for getting candies has worked wonderfully! Now he has an abundance of candies, but needs a machine to count these candies. Being very picky, he wants the machine to be able to answer queries about his candies.</p>
<p>Given \(N\) candies, each with a value \(v_i\), the machine must be able to answer queries about his candies, \(Q\) times.</p>
<p>Each query consists of a range \((1 \le l_i \le r_i \le N)\), you are to find the sum of all the value...TSSPC '20 Contest 1 P2 - Trick or Treat2021-03-06T16:56:30+00:002021-03-06T16:56:30+00:00https://tssoj.ca/problem/tsspc20c1p2<p>It's almost Halloween! Adam has devised a plan to get the most out of trick or treating. However, he wants to make sure his plan works correctly, so he has asked you to make a program to check how much value he gets out of trick or treating.</p>
<p>Given \(N\) candies, each candy with a value \(v_i\), he wants you to organize his bag so that he can get the greatest value!</p>
<p>Of course, each candy takes one unit of space, and in total he has \(S\) units of space in his bag! He cannot alway...TSSPC '20 Contest 1 P1 - Revenge2021-03-06T16:56:23+00:002021-03-06T16:56:23+00:00https://tssoj.ca/problem/tsspc20c1p1<p>In a the depths of a dark tunnel, you're mining diamonds under the light of a single torch. The spooky echoes of the cave grow thicker as you reach deep into the never ending darkness. Food is running low and you know you'll starve to death unless you turn back now and make it back in time with the diamonds. As you pack up your pickax, you hear a subtle hissing noise behind your head. Is it the sound of a creeper? At this moment you know hours of hard work could be lost, all the time you've p...Hockey Scores2020-11-23T02:03:29+00:002020-11-23T02:03:29+00:00https://tssoj.ca/problem/hockeyscores<p>Hugh Hockey is a very big hockey fan. Every Saturday night he sits and watches all the hockey games, never wanting to miss a moment. Every Canadian loves hockey.</p>
<p>Not this Saturday night though. Hugh Hockey has a date, so he trained his three year-old brother Billy to record the scores for him. He sits Billy in front of his TV, teaches him how to change the channels, and tells him to write down the hockey scores.</p>
<p>Hugh returns home, after his date, to a surprise: he discovers that...UK Postal Codes2020-05-21T22:46:38+00:002020-05-21T22:46:38+00:00https://tssoj.ca/problem/ukcodes<p>A postal code in the United Kingdom must come in one of the following formats:</p>
<pre><code>A9 9AA
A9A 9AA
A99 9AA
AA9 9AA
AA9A 9AA
AA99 9AA</code></pre>
<p>In the above formats, <code>A</code> is a placeholder for any lowercase <em>or</em> uppercase letter and <code>9</code> is a placeholder for any digit. For example <code>e5Y 8Qe</code> is a valid UK postal code because it follows the second format listed above. Given a string, determine if it is a valid UK postal code.</p>
<h4>Input Sp...A Baker's Dozen2020-05-21T22:16:04+00:002020-05-21T22:16:04+00:00https://tssoj.ca/problem/bakersdozen<p>When ordering a quantity of pastries, a baker's dozen is considered to be 13. At TSS Bakery, you are charged the cost of a dozen pastries when you purchase a baker's dozen, effectively giving you 1 for free. In addition to a separate cost for a dozen, there is another cost for individual pastries below a dozen. Given the costs as well as the number of pastries purchased, determine the final amount of the bill.</p>
<h4>Input Specification</h4>
<p>The first line of input is an integer \(b\) \((...Leap Year2020-05-14T11:47:03+00:002020-05-14T11:47:03+00:00https://tssoj.ca/problem/leapyear<p>A Leap Year is any year which satisfies one of the following conditions:</p>
<ul>
<li>The year is a multiple of 4, 100 and 400. </li>
<li>The year is a multiple of 4 but not a multiple of 100.</li>
</ul>
<p>Given a year, determine if it is a Leap Year. You may copy and paste the following Python function to check if a number is a multiple of another.</p>
<div class="codehilite"><pre><span></span><code><span class="k">def</span> <span class="nf">is_multiple</span><span class="p">(</span><span...Off Peak2020-05-12T23:56:09+00:002020-05-12T23:56:09+00:00https://tssoj.ca/problem/offpeak<p>When calculating electricity bills, the hourly rate is based off of the time of day. During "on peak" hours, the hourly rate is higher then during "off peak" hours. Given a number, determine if it is a valid hour of the day (using 24 hour time) and if it is, determine if it is on peak or off peak. On peak hours are between and including 9 and 17 (5pm) o'clock. Off peak hours are any other time of day. Numbers greater then 24 are not valid times of day.</p>
<h4>Input Specification</h4>
<p>The ...Integer Type2020-05-12T23:47:08+00:002020-05-12T23:47:08+00:00https://tssoj.ca/problem/integertype<p>Strings can represent even or odd numbers, but they also might not be numbers at all. Given a string, determine if it is an even integer, odd integer, or not an integer.</p>
<h4>Input Specification</h4>
<p>The only line of input is an alphanumeric sequence of characters containing only digits and lowercase letters.</p>
<h4>Output Specification</h4>
<p>If the input was an even integer, print <code>even</code>, if it was an odd integer, print <code>odd</code>. If it was not a valid integer, pri...Max of Three2020-05-12T22:05:45+00:002020-05-12T22:05:45+00:00https://tssoj.ca/problem/maxofthree<p>Given three numbers, your task is to determine which of them is the biggest.</p>
<h4>Input Specification</h4>
<p>There will be three lines of input each containing an integer between <code>1</code> and <code>1 million</code>.</p>
<h4>Output Specification</h4>
<p>Print the greatest integer of the three.</p>
<h4>Sample Input</h4>
<pre><code>8392
52
53494</code></pre>
<h4>Sample Output</h4>
<pre><code>53494</code></pre>
...Roman Numerals I2020-05-12T21:22:02+00:002020-05-12T21:22:02+00:00https://tssoj.ca/problem/romannumeralsi<p>The numbering system we use today is known as <em>Arabic Numerals</em>. The ancient Romans used a numbering system called <em>Roman Numerals</em>. The following is a conversion table for converting Arabic Numerals to Roman Numerals.</p>
<pre><code>1 I
2 II
3 III
4 IV
5 V
6 VI
7 VII
8 VIII
9 IX
10 X</code></pre>
<p>Given an Arabic Numeral from <code>1-10</code>, determine the corresponding Roman Numeral.</p>
<h4>Input Specification</h4>
<p>The only line of input i...Character Switch2020-04-16T14:13:50+00:002020-04-16T14:13:50+00:00https://tssoj.ca/problem/charswitch<p>Write a program that takes a string of length at least two as input and then prints a string formed by exchanging the first and last characters in the string provided.</p>
<h4>Input</h4>
<p>A String of length 2 or more.</p>
<h4>Output</h4>
<p>A new String that has the first and last characters switched.</p>
<h4>Sample Input</h4>
<pre><code>red</code></pre>
<h4>Sample Output</h4>
<pre><code>der</code></pre>
...Heart Rate2020-04-15T23:36:05+00:002020-04-15T23:36:05+00:00https://tssoj.ca/problem/heartrate<p>The target heart rate can be obtained by adding the resting heart rate to the product of the target intensity (a number between 0 and 1) and the heart rate reserve.</p>
<p>The heart rate reserve is the difference between the maximum heart rate and the resting heart rate.</p>
<p>The maximum heart rate is calculated as 220 minus the age.</p>
<p>For the values given, print the target heart rate.</p>
<h4>Input</h4>
<p>The inputs are age, resting heart rate and intensity.</p>
<h4>Output</h4>
<p>Th...Backwards Tree2020-03-12T21:59:07+00:002020-03-12T21:59:07+00:00https://tssoj.ca/problem/backwardstree<p>Leonhard Euler famously solved The Seven Bridges of Königsberg problem, leading to the establishment of graph theory. Overjoyed by the creation of a new branch of mathematics, Euler decided to pose himself a problem.</p>
<p>First, Euler gives himself \(N\) nodes and \(N-1\) edges to build a <strong>directed graph (a directed tree with all edges pointing away from root node)</strong>, labelling each node from \(1\) to \(N\). The \(i^{th}\) node is assigned a value, \(V\), of \(\frac{1}{2^i}\)....Jonathan Sumabat 9.52020-03-12T00:48:57+00:002020-03-12T00:48:57+00:00https://tssoj.ca/problem/0jsumabat9point5<p>Jonathan Sumabat is a world class Osu! player. He is known for developing new techniques to play that have been widely adapted across the game. One of these techniques is called <em>hacking into Osu! servers and changing the score</em>. This is where Jonathan Sumabat hacks into Osu! servers and changes his score. However, due to his limited access, the only option he has is to switch the first and last digits of his score. After changing a number of different scores, Jonathan Sumabat forgets ...Theory of Relativity2020-03-10T17:32:43+00:002020-03-10T17:32:43+00:00https://tssoj.ca/problem/theoryofrelativity<p>Albert Einstein was a renowned theoretical physicist who developed the famous equation \(E=mc^2\). Albert Einstein is now working on a thesis he calls the Theory of Special Relativity which posits a set of universal truths about the behavior of light and motion of objects. When developing his thesis, Einstein selects evidence to support his hypothesis based on a "reliability ratio". He selects a set of trials from various different experiments such that the sum of the reliability ratio is max...Lady of the Lake2020-03-09T17:15:57+00:002020-03-09T17:15:57+00:00https://tssoj.ca/problem/ladyofthelake<p>King Arthur Pendragon is said to have been a great king of Britain, wielding the legendary sword Excalibur. After his final battle and the defeat of his nemesis, Mordred, King Arthur must return his sword to the one who gave it to him, the Lady of the Lake. The Lady of the Lake speaks an ancient language that only King Arthur understands. To the human ear, the language of the Lady of the Lake takes every letter in her speech, and shifts forward every letter by the absolute value of the differ...Encryption by Reversal2020-03-07T01:35:22+00:002020-03-07T01:35:22+00:00https://tssoj.ca/problem/encryptionbyreversal<p>John von Neumann was a Hungarian-American scholar who worked on developing the world's first nuclear weapons during World War II. He is highly regarded as one of the greatest mathematicians of his time. One day, John von Neumann is testing a new algorithm he created called "Mergesort" using a set of numbers he generated. Because he wants to keep his work on Mergesort secret, John von Neumann devises a way to encrypt his numbers. Starting from the original sorted set of numbers, he selects som...Cinematography2020-03-05T23:41:13+00:002020-03-05T23:41:13+00:00https://tssoj.ca/problem/cinematography<p>Charlie Chaplin is seen as one of the most influential cinematographers of all time, rising to fame during the era of silent film. During this era, film was projected onto the big screen from a roll of tape. The film is connected from beginning to end, meaning after the film finishes rolling, it is looped back to the start and played again. At a screening of one of his films, Charlie Chaplin notices that the film roll is misaligned in the projector, causing the movie to start from somewhere i...