Recently Added TSSOJ Problemshttps://tssoj.ca/2024-03-04T05:00:00+00:00The latest problems added on the Thornhill Secondary School Online Judge websiteCCC '24 S2 - Heavy-Light Composition2024-03-04T05:00:00+00:002024-03-04T05:00:00+00:00https://tssoj.ca/problem/ccc24s2<p><strong>Canadian Computing Competition: 2024 Stage 1, Senior #2</strong></p>
<p>In a string containing only lowercase letters of the alphabet (<code>a</code> through <code>z</code>), we say a letter is heavy if it appears more than once in the string, and light otherwise.</p>
<p>We will be given a number of strings. For each string, we would like to determine whether the letters of the string alternate between light and heavy.</p>
<h4>Input Specification</h4>
<p>The first line of input will c...CCC '24 S1 - Hat Circle2024-03-04T05:00:00+00:002024-03-04T05:00:00+00:00https://tssoj.ca/problem/ccc24s1<p><strong>Canadian Computing Competition: 2024 Stage 1, Senior #1</strong></p>
<p>At a recent social gathering, \(N\) people sit around a circular table, where \(N\) is even. The seats are numbered clockwise from \(1\) to \(N\). Each person is wearing a hat with a number on it. Specifically, the person at seat \(i\) is wearing a hat with the number \(H_{i}\) on it.</p>
<p>Each person looks at the person who is directly across (diametrically opposite) them in the circle.</p>
<p>Determine the num...CCC '24 J5 - Harvest Waterloo2024-03-04T05:00:00+00:002024-03-04T05:00:00+00:00https://tssoj.ca/problem/ccc24j5<p><strong>Canadian Computing Competition: 2024 Stage 1, Junior #5</strong></p>
<p>There is a wildly popular new harvest simulation game called Harvest Waterloo. The game is played on a rectangular pumpkin patch which contains bales of hay and pumpkins of different sizes. To begin the game, a farmer is placed at the location of a pumpkin.</p>
<p>The farmer harvests all pumpkins they can reach by moving left, right, up, and down throughout the patch. The farmer cannot move diagonally. The farmer ...CCC '24 J4 - Troublesome Keys2024-03-04T05:00:00+00:002024-03-04T05:00:00+00:00https://tssoj.ca/problem/ccc24j4<p><strong>Canadian Computing Competition: 2024 Stage 1, Junior #4</strong></p>
<p>As Alex is typing, their keyboard is acting strangely. Two letter keys are causing trouble:</p>
<ul>
<li>One letter key displays the same wrong letter each time it is pressed. Alex calls this key the silly key. Oddly, Alex never actually tries to type the wrong letter displayed by the silly key.</li>
<li>Another letter key doesn't display anything when it is pressed. Alex calls this key the quiet key.
Alex presses...CCC '24 J3 - Bronze2024-03-04T05:00:00+00:002024-03-04T05:00:00+00:00https://tssoj.ca/problem/ccc24j3<p><strong>Canadian Computing Competition: 2024 Stage 1, Junior #3</strong></p>
<p>After completing a competition, you are struck with curiosity. How many participants were awarded bronze level?</p>
<p>Gold level is awarded to all participants who achieve the highest score. Silver level is awarded to all participants who achieve the second highest score. Bronze level is awarded to all participants who achieve the third highest score.</p>
<p>Given a list of all the scores, your job is to determin...CCC '24 J2 - Dusa And The Yobis2024-03-04T05:00:00+00:002024-03-04T05:00:00+00:00https://tssoj.ca/problem/ccc24j2<p><strong>Canadian Computing Competition: 2024 Stage 1, Junior #2</strong></p>
<p>Dusa eats Yobis, but only Yobis of a certain size.</p>
<p>If Dusa encounters a Yobi that is smaller than itself, it eats the Yobi, and absorbs its size. For example, if Dusa is of size \(10\) and it encounters a Yobi of size \(6\), Dusa eats the Yobi and expands to size \(10 + 6 = 16\).</p>
<p>If Dusa encounters a Yobi that is the same size as itself or larger, Dusa runs away without eating the Yobi.</p>
<p>Dusa i...CCC '24 J1 - Conveyor Belt Sushi2024-03-04T05:00:00+00:002024-03-04T05:00:00+00:00https://tssoj.ca/problem/ccc24j1<p><strong>Canadian Computing Competition: 2024 Stage 1, Junior #1</strong></p>
<p>There is a new conveyor belt sushi restaurant in town. Plates of sushi travel around the restaurant on a raised conveyor belt and customers choose what to eat by removing plates.</p>
<p>Each red plate of sushi costs \($3\), each green plate of sushi costs \($4\), and each blue plate of sushi costs \($5\).</p>
<p><img src="https://static.dmoj.ca/media/martor/d70c57cc-648a-494a-a713-d20f5163ce96.png" alt="Plates of...TCCC '24 Feb P3 - Snowy Days2024-02-16T05:00:00+00:002024-02-16T05:00:00+00:00https://tssoj.ca/problem/tccc24feb3<p><strong>Thornhill Computer Club 2024 - February Mock CCC - Problem 3</strong></p>
<p>Joe likes to go sledding. Of course, to go sledding, there must be snow. On any given day, snow will form if the temperature is below <code>0</code> degrees Celsius and the humidity is above <code>70</code> percent. However, Joe is an elitist sledder and will only go sledding if there is sufficient snow. Specifically, he will only go sledding on a given day if it has been snowing for at least two consecutive ...TCCC '24 Feb P1 - Morning Routine2024-02-16T05:00:00+00:002024-02-16T05:00:00+00:00https://tssoj.ca/problem/tccc24feb1<p><strong>Thornhill Computer Club 2024 - February Mock CCC - Problem 1</strong></p>
<p>[user:KurbyDoo] always stays up late and can never fall asleep on time. As a result, he often wakes up late for school causing him to skip breakfast and even potentially <strong>miss the bus</strong> which always arrives exactly <strong>8 hours after midnight</strong>. Aware of his problem, he decides to plan his morning routine accordingly depending on when he wakes up. It takes <code>5</code> minutes for hi...TCCC '24 Feb P4 - Good Gifts2024-02-16T05:00:00+00:002024-02-16T05:00:00+00:00https://tssoj.ca/problem/tccc24feb4<p><strong>Thornhill Computer Club 2024 - February Mock CCC - Problem 4</strong></p>
<p>During a party, people exchange gifts. Every person has written their favourite number on the gifts that they will give. If the sum of the numbers of the gifts exchanged between two people is prime, their exchange is considered a good exchange. Every person can give infinitely many gifts, but any pair of two people may only exchange their gifts once.</p>
<p>Given the number of people at the party and their fa...TCCC '24 Feb P5 - Mars Adventure2024-02-16T05:00:00+00:002024-02-16T05:00:00+00:00https://tssoj.ca/problem/tccc24feb5<p><strong>Thornhill Computer Club 2024 - February Mock CCC - Problem 5</strong></p>
<p>[user:EthanPacker] has made it to Mars! After spending many days aboard his rocket, he has finally touched down and deployed his rover to explore the Martian surface. However, Mars is a hostile planet with different terrains requiring a different amount of energy to cross. What makes matters even worse, is that [user:EthanPacker] forgot to charge the rover before blasting off! Given multiple queries, determin...TCCC '24 Feb P2 - Mountain Misfortune2024-02-15T17:38:01+00:002024-02-15T17:38:01+00:00https://tssoj.ca/problem/tccc24feb2<p><strong>Thornhill Computer Club 2024 - February Mock CCC - Problem 2</strong></p>
<p>[user:KurbyDoo] is climbing up a mountain. Unfortunately he tripped over a rock and is now tumbling down! As he falls, he hits rocks on the way down and each time he does, he screams "OUCH". [user:krem] finds [user:KurbyDoo]'s predicament extremely funny and decides to record the audio. Watching the file back, determine how many times [user:KurbyDoo] hit a rock while falling.</p>
<h4>Input Specifications</h4>...TCCC '23 Dec P3 - Escaping The Mines2023-12-22T07:35:00+00:002023-12-22T07:35:00+00:00https://tssoj.ca/problem/tccc23dec3<p><strong>Thornhill Computer Club 2023 - December Contest - Problem 3</strong></p>
<p>In the last chronological problem, the Elves were hard at work trying to find all of the mine's coal and mine it as fast as possible. After a long time of mining, the Elves notice that they are mining more coal than anywhere else in the world. Not wanting to provide lumps of coal to all the naughty children, the Elves start a worker's revolt throughout Santa's Arctic coal mine so they can reap the profits of s...TCCC' 23 Dec P4 - The Bronze Christmas Tree2023-12-18T16:40:18+00:002023-12-18T16:40:18+00:00https://tssoj.ca/problem/tccc23dec4<div style="float:right; width:400px; padding: 10px 10px">
<img src="https://imgs.xkcd.com/comics/tree.png" style="display: block; margin: 0 auto; width:100%;">
<div style="text-align:center;font-style:italic;margin-top:0.5em"><a href="http://xkcd.com/835/" title="a" rel="nofollow">The Average Christmas Tree</a></div></div><p>With 2.9 million beautiful grins on 2.9 million proud elves standing at the front gates of Santa's present factory, What was once a place of terror and monotonous labour is...TCCC '23 Dec P2 - Grinching2023-12-10T00:53:44+00:002023-12-10T00:53:44+00:00https://tssoj.ca/problem/tccc23dec2<p><strong>Thornhill Computer Club 2023 - December Contest - Problem 1</strong></p>
<blockquote><p><em>The 30th of November by The Ministry of Elvish Affairs</em><br>
`Twas the season once more, proclaimed Saint Nick bold, Through the elf village, his voice mighty and old.<br>
Conscripting young elves, six and above, For the Christmas crunch, a mission of love.</p>
<p>Unaware was dear Santa, of the plot in the air, A local elf youth grinned with a mischievous stare.<br>
A grand "Grinching" schem...TCCC '23 Dec P1 - The Jolly Mines2023-12-10T00:51:13+00:002023-12-10T00:51:13+00:00https://tssoj.ca/problem/tccc23dec1<p>After being arrested by the North Pole Police Department (NPPD) for aggregate grand thefts from their little "Grinching" scheme, the elves were now all together in Santa's infamous "Jolly" coal mines. Turns out Santa had silently updated the security systems to allow the elves to individually build up a theft profile of over $30,000 each, escalating their petty thefts to an aggregate felony. In the spirit of giving or spite, the disciplinary elf Brian decided that the elves should be allowed ...CCC '18 J5 - Choose your own path2023-12-08T20:18:07+00:002023-12-08T20:18:07+00:00https://tssoj.ca/problem/ccc18j5<p><strong>Canadian Computing Competition: 2018 Stage 1, Junior #5</strong></p>
<p>There is a genre of fiction called choose your own adventure books. These books allow the reader to make choices for the characters which alters the outcome of the story.</p>
<p>For example, after reading the first page of a book, the reader may be asked a choice, such as "Do you pick up the rock?" If the reader answers "yes", they are directed to continue reading on page
, and if they choose "no", they are direc...TCCC '23 Nov P6 - String Permutations2023-12-01T05:00:06+00:002023-12-01T05:00:06+00:00https://tssoj.ca/problem/tccc23nov6<p>[user:KurbyDoo] has recently become obsessed with strings and poses the following question</p>
<blockquote><p>Given a string of length \(S\) and \(Q\) queries, output how many permutations there are of the substring between index \(L\) and \(R\) (inclusive)</p>
</blockquote>
<p>Can you help [user:KurbyDoo] answer his question?</p>
<h4>Input Specification</h4>
<p>The first line will contain two integers \(|S|\) \((1 \le |S| \le 10^5)\) length of the string, and \(Q\) \((1 \le Q \le 10^5)\) the...TCCC '23 Nov P5 - The Silver Hedgehog2023-12-01T05:00:05+00:002023-12-01T05:00:05+00:00https://tssoj.ca/problem/tccc23nov5<p>On a warm summer's day, brothers Ohani and Inaho are playing legos with each other. Out of nowhere, Ohani mentions his encounter with a golden porcupine earlier this morning. Excited, Inaho then makes a blood pact with his brother to solve the golden porcupine's riddles by tonight, both brothers love computer science.</p>
<p>Inaho grabs his metal detector and enters the magical forest to search for the golden porcupine. He searches for 2 \((2 \le 2 \le 2)\) minutes but finds nothing and gives...TCCC '23 Nov P4 - Special Sequential Letter Sequences2023-12-01T05:00:04+00:002023-12-01T05:00:04+00:00https://tssoj.ca/problem/tccc23nov4<p>A sequence of letters is called a word. A sequence of letters is considered special if all the characters within the word are unique (There are no duplicate letters).</p>
<p>Given a sequence of letters \(S\) and \(Q\) queries, for each query, determine the number of possible Special Sequences that can be created using all the unique characters between index \(L\) and \(R\) (inclusive) of string \(S\).</p>
<h4>Input Specification</h4>
<p>The first line will consist of two integers \(|S|\) \((1...TCCC '23 Nov P3 - Maximal Candy Operation2023-12-01T05:00:02+00:002023-12-01T05:00:02+00:00https://tssoj.ca/problem/tccc23nov3<div style="float:right; width:400px; padding: 20px 20px">
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUSExMWFhUXGRgbGRgYGBgdGBggGhgYGhggHRgfHyggGCElGxgYITEhJSkrLi4uGR8zODMtNygtLisBCgoKDg0OGxAQGy8mICUtLy0tLy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAJ8BPgMBIgACEQEDEQH/xAAcAAACAwEBAQEAAAAAAAAAAAAFBgMEBwIBAAj/xABDEAACAQIEBAQEBAQFAgQHAQABAhEDIQAEEjEFBiJBE1FhcTKBkaEjQrHBFFLR8AdicuHxFYIkM7LCNENTY5Ki0hb/xAAaAQADAQEBAQAAAAAAAAAAAAADBAUCAQAG/8QAOREA...TCCC '23 Nov P2 - Candy Stash2023-12-01T05:00:01+00:002023-12-01T05:00:01+00:00https://tssoj.ca/problem/tccc23nov2<p>The day before Halloween, many shoppers attempt to buy candy last minute, causing candy stores to run out of candy. Luckily, one candy store is well prepared having ordered candies in advance to be delivered on this day.</p>
<p>Throughout the day, batches of candy are delivered to the store, with each candy having an associated sweetness value. Since the store remains open 24/7, shoppers also come to purchase candy while deliveries may be occurring. The shelves are stocked depending on the st...TCCC '23 Nov P1 - Standard Guidelines2023-12-01T05:00:00+00:002023-12-01T05:00:00+00:00https://tssoj.ca/problem/tccc23nov1<p>At the cardboard box factory, \(N\) boxes (\(1 \le N \le 10^3\)) are produced every day, each with a side length of \(S\) (\(1 \le S \le 10^3\)). In order to preserve the company's reputation, the stability of the boxes must be tested according to \(N\) standard guidelines. The \(i\)th guideline states that a tower with a minimum height of \(H_i\) (\(1 \le H_i \le 10^6\)) must be achievable by stacking <strong>exactly</strong> \(i\) boxes on top of one another. Each box is perfectly symmetric...Matrix Test2023-11-13T05:00:00+00:002023-11-13T05:00:00+00:00https://tssoj.ca/problem/matrixtest<p>[user:KurbyDoo] has just learned about 2d matrices! Unfortunately, he can never seem to implement them properly.</p>
<p>Can you show him how its done?</p>
<h4>Input Specifications</h4>
<p>The first line will contain two integers \(N\) \((1 \le N \le 250)\) and \(M\) \((1 \le M \le 250)\) the number of rows and the number of columns in the matrix.<br>
The next \(N\) lines will contain \(M\) space separated integers \(v_{ij}\) \((1\le v_{ij} \le 10^9)\), the value in the \(i\)th row and \(j\)th...USACO 2023 February Silver P1 - Bakery2023-11-11T05:00:00+00:002023-11-11T05:00:00+00:00https://tssoj.ca/problem/usaco23febs1<p>Bessie has opened a bakery!</p>
<p>In her bakery, Bessie has an oven that can produce a cookie in \(t_C\) units of time or a muffin in \(t_M\) units of time (\(1\le t_C, t_M \le 10^9\)). Due to space constraints, Bessie can only produce one pastry at a time, so to produce \(A\) cookies and \(B\) muffins, it takes \(A \cdot t_C + B \cdot t_M\) units of time.</p>
<p>Bessie's \(N\) (\(1 \le N \le 100\)) friends would each like to visit the bakery one by one. The \(i\)th friend will order \(a_i\)...