Recently Added TSSOJ Problemshttps://tssoj.ca/2022-11-01T14:51:45+00:00The latest problems added on the Thornhill Secondary School Online Judge websiteTSS '22 CC P4 - Ancient Castle Ruins2022-11-01T14:51:45+00:002022-11-01T14:51:45+00:00https://tssoj.ca/problem/tss22ccp4<p>You stumble across the ruins of an ancient castle...</p>
<p>The ruins of the castle have left a strange pillar formation behind. In particular, there are \(N\) adjacent pillars each with height \(h_i\). Let \(x\) represent your exhaustion. It initally starts at \(1\), and increases by \(1\) after each time you jump to a <strong>taller</strong> pillar. It takes \(x\) seconds to travel from pillar \(i\) to pillar \(i+1\) if \(h_i \ge h_{i+1}\). However, there are \(2\) different ways to travel ...TSS '22 CC P3 - Treasure Hunt in the Jungle2022-11-01T14:51:22+00:002022-11-01T14:51:22+00:00https://tssoj.ca/problem/tss22ccp3<p>You stumble across a jungle rumored to have ancient treasures in it. Luckily, you have a map of the jungle with the locations of the treasure chests.</p>
<p>Your map contains the following legend:</p>
<table class="table" style="width: fit-content; margin: 0">
<tr>
<th>Symbol</th>
<th>Description</th>
</tr>
<tr>
<td><code>.</code></td>
<td>Terrain you may walk through</td>
</tr>
<tr>
<td><code>X</code></td>
<td>A t...TSS '22 CC P2 - River Crossing2022-11-01T14:50:21+00:002022-11-01T14:50:21+00:00https://tssoj.ca/problem/tss22ccp2<p>You find yourself in front of a long river and decide to cross it safely...</p>
<p>There are \(N\) stones scattered throughout the river that you can jump on in order to make it to the other side. You start at position \(0\) and the river ends at position \(M\).</p>
<p>From any given point, you can jump up to \(K\) units forward, as long you don't land in the water. More specifically, you can jump on a stone at position \(a_i\) if \(|a_i - x| \le K\), where \(x\) represents your current posit...TSS '22 CC P1 - Mud Puddles2022-11-01T14:49:42+00:002022-11-01T14:49:42+00:00https://tssoj.ca/problem/tss22ccp1<p>You have decided to go hiking on a trail consisting of \(N\) characters.</p>
<p>Each character will be one of the following:</p>
<ul>
<li><code>-</code> representing dry ground</li>
<li><code>*</code> representing wet mud</li>
</ul>
<p>Before your trip, you decide to count the number of mud puddles to make sure you're not getting too dirty. Any contiguous sequence of <code>*</code> is considered one mud puddle.</p>
<p>Given \(N\) and a string representing the trail, output the total number of...Simple Valid Brackets2022-10-21T17:04:35+00:002022-10-21T17:04:35+00:00https://tssoj.ca/problem/simplevalidbrackets<p>For an extra challenge, check out <a href="https://tssoj.ca/problem/validbrackets" rel="nofollow">Valid Brackets</a>!</p>
<p>Determine if the given sequence of round brackets is valid. A sequence of brackets is considered valid if each opening bracket is paired with a closing bracket. The closing bracket can be anywhere in the sequence, as long as it comes after (to the right of) its corresponding pair. For example: <code>()()()</code>, <code>((()))</code>, <code>(())()</code>, <code>(()())</...How's the Weather2022-08-23T17:07:19+00:002022-08-23T17:07:19+00:00https://tssoj.ca/problem/howstheweather<p>You've had quite enough of confusing conversations with Americans who assume you're using Fahrenheit when Celsius is clearly the way to go. Rather than argue with them, you've settled for writing a program to conveniently convert temperatures measured in degrees Celsius to Fahrenheit instead.</p>
<p>You came across the following formula, which holds true given that \(F\) is a temperature in degrees Fahrenheit while \(C\) is that same temperature in degrees Celsius:</p>
<p>\[C=5/9*(F-32)\]</p>...An Honest Day's Work2022-08-09T23:35:27+00:002022-08-09T23:35:27+00:00https://tssoj.ca/problem/anhonestdayswork<p>Jessie, James, and Meowth, members of the honourable Team Rocket, have unfortunately fallen on hard times. With their funds necessarily allocated to constructing all manner of giant robots and other devices, they've been having difficulty affording any food lately. But that's nothing that an honest day's work can't fix!</p>
<p>James has a can of leftover paint, containing \(P(1 \le P \le 100)\) litres of the stuff. When combined with his boundless collection of bottlecaps, this can result in ...Next in Line2022-08-08T17:49:14+00:002022-08-08T17:49:14+00:00https://tssoj.ca/problem/nextinline<p>You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages could be 5, 10 and 15, since both adjacent pairs have a difference of 5 years.</p>
<p>Given the ages of the youngest and middle children, what is the age of the oldest child?</p>
<h4>Input Specification</h4>
<p>The input consists of two integ...A New Hope2022-08-08T17:36:23+00:002022-08-08T17:36:23+00:00https://tssoj.ca/problem/anewhope<p><em>Problem taken from <a href="https://dmoj.ca/problem/wc15c2j1" rel="nofollow">DMOJ</a></em></p>
<p>You might be aware that the events of the Star Wars saga took place a long time ago, in a galaxy that was rather far away. But just how far away was it? We can try to describe it by repeating the word <code>far</code> a certain number of times in the following sentence format:</p>
<p>\[\texttt{A long time ago in a galaxy far, far away...}\]</p>
<p>In the above example, the word <code>far</cod...A Spooky Season2022-08-08T17:32:23+00:002022-08-08T17:32:23+00:00https://tssoj.ca/problem/aspookyseason<p><em>Problem taken from <a href="https://dmoj.ca/problem/wc16c1j1" rel="nofollow">DMOJ</a></em></p>
<p>Late October can be a rather frightening time of year. Night begins to fall ever earlier, ancient Pagan rituals make demons stir, and at the end of the month, hordes of small creatures can even be seen roaming the streets! It's a spooky sight if there ever was one.</p>
<p>But just how spooky is this demonic festival? Its spookiness level can, in fact, be measured and represented as a single i...Core Drill2022-08-08T17:24:17+00:002022-08-08T17:24:17+00:00https://tssoj.ca/problem/coredrill<p><em>Problem taken from <a href="https://dmoj.ca/problem/dmopc14c5p1" rel="nofollow">DMOJ</a></em></p>
<p>Simon got a new drill recently. Everyone knows that a drill is shaped like a right circular cone. Simon knows his drill has radius \(r\) and height \(h\), But now he wants to calculate the volume. Write a program to help Simon!</p>
<p><strong>Note:</strong> The formula for the volume of a cone is \(V=\frac{\pi r^2h}{3}\)</p>
<h4>Input Specification</h4>
<p>The first line of input will have...Not a Wall of Text2022-08-08T17:05:10+00:002022-08-08T17:05:10+00:00https://tssoj.ca/problem/notawalloftext<p><em>Problem was taken from <a href="https://dmoj.ca/problem/dmopc15c7p2" rel="nofollow">DMOJ</a>.</em></p>
<p>Count the number of words in a text.</p>
<h4>Input Specification</h4>
<p>The input will be a text with only lowercase letters and spaces (ASCII code 32). The only constraint is that the length of the entire text will not exceed 80 characters. Also, there won't be anything tricky like double whitespace in a row, leading whitespace, or trailing whitespace.</p>
<h4>Output Specification<...Volleyball Game2022-07-27T16:44:44+00:002022-07-27T16:44:44+00:00https://tssoj.ca/problem/volleyballgame<p>Two teams, Team \(A\) and Team \(B\), are playing a volleyball game. In volleyball, the first team to reach at least 25 points with a 2 point difference or more wins the game. A team gets a point when the ball lands on the opponent's side of the court or when the opponent hits the ball out of bounds. Create a program that determines which team won.</p>
<h4>Input Specification</h4>
<p>The only line of input will be a string which is made solely from the characters <code>A</code> and <code>B</c...Elevator Doors2022-07-26T17:20:56+00:002022-07-26T17:20:56+00:00https://tssoj.ca/problem/elevatordoors<p>When a person presses the button to go into an elevator, the elevator on the nearest floor will travel to the user's floor and open its doors. You are tasked to determine which elevator out of two will open its doors for the person that presses the button.</p>
<h4>Input Specification</h4>
<p>There are three types of floors in the building: The main floors, the ground floor, and the parking floor. There will be three lines of input, all of them being a character that denotes the floors. The ma...Age Demographic2022-05-26T21:04:47+00:002022-05-26T21:04:47+00:00https://tssoj.ca/problem/demographic<p>You have just uploaded your first video as a content creator.</p>
<p>Curious about which audiences you should be targeting, you have gathered data about \(N\:(1 \le N \le 3 \cdot 10^5)\) different viewers. Specifically, you know the ages \(x_i\:(1 \le x_i \le 10^9)\) of every single person that has watched your video.</p>
<p>Given \(Q\:(1 \le Q \le 3 \cdot 10^5)\) different queries, how many people between the ages of \(a\) and \(b\) inclusive \((1 \le a, b \le 10^9)\) have watched your video...WC '17 Contest 3 J3 - Uncrackable2022-05-20T17:21:16+00:002022-05-20T17:21:16+00:00https://tssoj.ca/problem/wc17c3j3<h4>Woburn Challenge 2017-18 Round 3 - Junior Division</h4>
<p>You'd like to register an account on an extremely entertaining website. You've already selected a username, but it seems that the requirements for choosing a password are quite strict, in order to completely protect your account from being hacked into. The password must be a string between \(8\) and \(12\) characters long (inclusive), such that every character is either a lowercase letter (<code>a</code> … <code>z</code>), uppercase ...COCI '18 Contest 3 #1 Magnus2022-05-20T16:35:05+00:002022-05-20T16:35:05+00:00https://tssoj.ca/problem/coci18c3p1<p>Magnus lost a game of chess to Kile so he found comfort in competitive programming. Very soon, he heard of the iconic COCI competition and decided to try his luck there.</p>
<p>He wrote a mail to Kile: "<em>Dear Kile, please, prepare me for COCI. Magnus</em>".</p>
<p>Kile replied: "<em>You want to participate in COCI? All right, here's your warm-up task. A series of four consecutive letters of some word that make up the subword <code>HONI</code> (Croatian acronym for COCI) is called the HONI-...Three Cups2022-05-18T02:25:46+00:002022-05-18T02:25:46+00:00https://tssoj.ca/problem/coci06c5p1<h4>COCI '06 Contest 5 #1 Trik</h4>
<p>Jealous of Mirko's position as head of the village, Borko stormed into his tent and tried to demonstrate Mirko's incompetence for leadership with a trick.</p>
<p>Borko puts three opaque cups onto the table next to each other (opening facing down) and a small ball under the leftmost cup. He then swaps two cups in one of three possible ways a number of times. Mirko has to tell which cup the ball ends up under.</p>
<p><img src="https://static.dmoj.ca/texoid/0e...CCC '18 J1 - Telemarketer or not?2022-05-11T01:41:11+00:002022-05-11T01:41:11+00:00https://tssoj.ca/problem/ccc18j1<h4>Canadian Computing Competition: 2018 Stage 1, Junior #1</h4>
<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 <strong>8</strong> or <strong>9</strong>;</li>
<li>the last digit is an <strong>8</strong> or <strong>9</strong>;</li>
<li>the second and third digits ...CCC '19 J1 - Winning Score2022-05-10T20:35:05+00:002022-05-10T20:35:05+00:00https://tssoj.ca/problem/ccc19j1<h4>Problem Description</h4>
<p>You record all of the scoring activity at a basketball game. Points are scored by a 3-point shot, a
2-point field goal, or a 1-point free throw.
You know the number of each of these types of scoring for the two teams: the Apples and the
Bananas. Your job is to determine which team won, or if the game ended in a tie.</p>
<h4>Input Specification</h4>
<p>The first three lines of input describe the scoring of the Apples, and the next three lines of input
describe the ...Problem J1: Who is in the middle?2022-05-10T17:00:57+00:002022-05-10T17:00:57+00:00https://tssoj.ca/problem/ccc07j1<h4>Problem Description</h4>
<p>In the story Goldilocks and the Three Bears, each bear had a bowl of porridge to eat while sitting
at his/her favourite chair. What the story didn’t tell us is that Goldilocks moved the bowls around
on the table, so the bowls were not at the right seats anymore. The bowls can be sorted by weight
with the lightest bowl being the Baby Bear’s bowl, the medium bowl being the Mama Bear’s bowl
and the heaviest bowl being the Papa Bear’s bowl. Write a program that reads ...CCC '15 J2 - Happy or Sad2022-05-10T02:14:05+00:002022-05-10T02:14:05+00:00https://tssoj.ca/problem/ccc15j2<h4>Problem Description</h4>
<p>We often include emoticons in our text messages to indicate how we are feeling. The three consecutive characters <code>:-)</code> indicate a happy face and the three consecutive characters <code>:-(</code> indicate a sad face. Write a program to determine the overall mood of a message.</p>
<h4>Input Specification</h4>
<p>There will be one line of input that contains between <strong>1</strong> and <strong><em>255</em></strong> characters.
Output Specification
The o...CCC '15 J1 - Special Day2022-05-09T23:24:13+00:002022-05-09T23:24:13+00:00https://tssoj.ca/problem/ccc15j1<h4>Canadian Computing Competition: 2015 Stage 1, Junior #1</h4>
<p>February 18 is a special date for the CCC this year.</p>
<p>Write a program that asks the user for a numerical month and numerical day of the month and then determines whether that date occurs before, after, or on February 18.</p>
<ul>
<li>If the date occurs before February 18, output the word <code>Before</code>. </li>
<li>If the date occurs after February 18, output the word <code>After</code>. </li>
<li>If the date is Februar...CCC '06 J1 - Canadian Calorie Counting2022-05-06T18:48:17+00:002022-05-06T18:48:17+00:00https://tssoj.ca/problem/ccc06j1<h4>Problem Description</h4>
<p>At Chip's Fast Food emporium there is a very simple menu. Each food item is selected by entering a digit choice.</p>
<table class="table" style="width: 500px;">
<tbody><tr>
<td style="text-align: left;">
Here are the three burger choices:<br>
1 – Cheeseburger (461 Calories)<br>
2 – Fish Burger (431 Calories)<br>
3 – Veggie Burger (420 Calories)<br>
4 – no burger</td>
<td style="text-align: left;">
Here are the three drink choices:<br>
1 – Soft Drink (130 Calories)...Victor's Various Adventures - Victor Writes A Math Contest2022-03-20T21:14:15+00:002022-03-20T21:14:15+00:00https://tssoj.ca/problem/victor4<p><strong><em>This is problem 4 of the <code>Victor's Various Adventures</code> problem set.</em></strong></p>
<p>Victor is writing a math contest, and easily solves all of the problems. However, he wants to test you with a very easy problem that was on the contest. To make it even easier for you, he has decided that you can write a program to solve the problem. The problem is as follows:</p>
<blockquote><p>We define an <em>expression</em> as something that can be evaluated to a real number, or...