Recently Added DMOJ Problemshttps://dmoj.ca/2017-09-20T03:24:28+00:00The latest problems added on the DMOJ: Modern Online Judge websiteTSS Club Fair 2017 Problem A2017-09-20T03:24:28+00:002017-09-20T03:24:28+00:00https://dmoj.ca/problem/tss17a<div><p>In space, satellites are constantly bombarded with radiation from the sun. The radiation can cause software glitches by changing the stored memory on the satellite. To defend against this, programmers often run \(3\) copies of the program at once. This way, the satellite can check which copy of the program is different from the majority to detect errors, then copy over the correct solution from the other programs. However, this system is not fail-proof. Occasionally, \(2\) pieces of memo...TSS Club Fair 2017 Problem B2017-09-20T03:24:24+00:002017-09-20T03:24:24+00:00https://dmoj.ca/problem/tss17b<div><p>There's a crisis in Hawaii! The great volcano "Mauna Loa" is about to erupt! The Mauna Loa is located in the middle of the largest island in Hawaii, with almost \(200\,000\) people living nearby.</p>
<p>As a responsible dictator, Joey quickly pulled out a map containing the locations of all \(N\) houses on the island. He come up with \(Q\) different scenarios on how the volcano might explode. Each scenario will describe the range of the volcano. Any house within the range of the volcano ...Back to School '17: Big Integer2017-09-11T19:45:35+00:002017-09-11T19:45:35+00:00https://dmoj.ca/problem/bts17p8<div><p>Nathan is a big fan of recreational mathematics. For one of his problems, he needs to add together very large numbers. He created a class called <code>BigInteger</code> to help with the adding, but he isn't done yet! Nathan needs to stress test his code, so he devised the following problem.</p>
<p>There will be \(N\) instructions (which are given as a string of length \(N\)). There are two types of instructions:</p>
<ul>
<li><code>0</code> to <code>9</code>: Add this digit to the end of ...Back to School '17: Hot and Cold2017-09-11T19:45:29+00:002017-09-11T19:45:29+00:00https://dmoj.ca/problem/bts17p7<div><p>You are overseeing a game of Hot and Cold on an unweighted bidirectional tree with \(N\) nodes (numbered \(1\) to \(N\)). In this game, you are the leader and there are \(S\) seekers, each playing their own individual game. This means that the game of one seeker does not impact the game of any other.</p>
<p>Each seeker and their game is characterized by three integers, \(a_s\), \(b_s\) and \(t_s\). The target node, \(t_s\), is the node that they are trying to find. The seeker will then t...Back to School '17: Sour Candy2017-09-11T19:45:22+00:002017-09-11T19:45:22+00:00https://dmoj.ca/problem/bts17p6<div><p>One summer day, April bought \(N\) pieces of sour candy to eat. Each piece of candy has a unique sourness value \(s_{n}\) which indicates how sour it is.</p>
<p>Initially, the candy pieces were lined up in a straight line. However, April wants to change the order of the candies by taking any piece of candy, and placing it either at the front or back of the line. Given the order April wants to place the candies in, find the minimum number of moves needed to place them in that arrangement....Back to School '17: New English2017-09-11T19:45:17+00:002017-09-11T19:45:17+00:00https://dmoj.ca/problem/bts17p5<div><p>Summer is an employee of a certain company which tries to create viral trends. The company's latest scheme is to create a single word which will then be adopted by the "youth" and become a meme. Summer is put in charge of this project, and she decides the word should have exactly \(N\) <strong>lowercase</strong> letters.</p>
<p>Excited by the possibility of a new internet sensation, \(M\) of Summer's friends each make one suggestion as to what the word should contain. Specifically, each ...Back To School '17: Wet Mud2017-09-11T19:45:12+00:002017-09-11T19:45:12+00:00https://dmoj.ca/problem/bts17p4<div><p>Denesh is walking along a pathway in a forest. He encounters a part of the trail where there is a patch of wet mud that is \(N\) inches long. The trail continues on the other side of the wet mud. Denesh just bought a new pair of shoes so he doesn't want to ruin them by stepping in wet mud, but he is fine with stepping in dry mud. Luckily, \(M\) parts of mud, each being 1 inch in length, will dry at different points in time. No two parts of mud can become dry at the same time.</p>
<p>Dene...Back To School '17: Physics2017-09-11T19:45:06+00:002017-09-11T19:45:06+00:00https://dmoj.ca/problem/bts17p3<div><p>To scientifically round a real number, find the integer that is the closest to the real number. If there are two equally close integers, choose the even integer. A few examples are listed in the table below.</p>
<table class="table" style="width:60%">
<tr>
<th>Real number</th>
<th>Rounded value</th>
<th>Comment</th></tr>
<tr>
<td>\(3.14\)</td>
<td>\(3\)</td>
<td>\(3\) is the closest integer to \(3.14\).</td></tr>
<tr>
<td>\(8.50\)</td>
<td>\(8\)</td>
<td>\(8\) and \(9\) are equally clo...Back to School '17: Avalon2017-09-11T19:44:59+00:002017-09-11T19:44:59+00:00https://dmoj.ca/problem/bts17p2<div><p>[user:vev] is addicted to the game <a href="https://boardgamegeek.com/boardgame/128882/resistance-avalon" rel="nofollow">Avalon</a>. She is currently playing a game and wants to make an informed decision on who to put on her quest. There are \(G\) distinct groups of players, each with \(p_{g}\) players. Of the \(p_{g}\) players in the group, \(e_{g}\) of them are considered to be evil (\(e_g \le p_g\)). Assuming [user:vev] chooses a single player randomly from each group, what is the pro...Back To School '17: ðŸ…±aramðŸ…±e2017-09-11T19:44:48+00:002017-09-11T19:44:48+00:00https://dmoj.ca/problem/bts17p1<html><head><style>h2,.content-description{font-family:Comic Sans MS,Trebuchet MS,Segoe UI,Lucida Grande,Arial,sans-serif;}</style></head><body><p>[user:d] needs help editing his assignment for English class. He forgot to use periods, and needs your help to fix the errors in his assignment.</p>
<p>If there is a word that starts with a capital letter, then there should be a period in front of the word before it. Also, the text should end with a period.</p>
<h4>Input Specifications</h4>
<p>The inp...CCC '04 S5 - Super Plumber2017-09-02T17:42:58+00:002017-09-02T17:42:58+00:00https://dmoj.ca/problem/ccc04s5<div><h5>Canadian Computing Competition: 2004 Stage 1, Senior #5</h5>
<p>You are to write a program to play a video game in which Super Plumber (SP) navigates
an obstacle course collecting prizes on the way to rescuing The Princess (TP).</p>
<p>The obstacle course is an \(m\) by \(n\) grid. SP starts at the bottom-left corner and makes his way to TP in the bottom-right corner. Some of the grid locations are occupied by obstacles through which SP cannot pass. Others are occupied by gold coins val...CCC '04 S4 - Space Turtle2017-09-02T17:33:07+00:002017-09-02T17:33:07+00:00https://dmoj.ca/problem/ccc04s4<div><h5>Canadian Computing Competition: 2004 Stage 1, Senior #4</h5>
<p>Space Turtle is a fearless space adventurer. His spaceship, the <em>Tortoise</em>, is a little outdated, but still gets him where he needs to go.</p>
<p>The <em>Tortoise</em> can do only two things â€“ move forward an integer number of light-years,
and turn in one of four directions (relative to the current orientation): right, left, up and down. In fact, strangely enough, we can even think of the Tortoise as a ship which tra...CCC '04 S3 - Spreadsheet2017-09-02T17:33:00+00:002017-09-02T17:33:00+00:00https://dmoj.ca/problem/ccc04s3<div><h5>Canadian Computing Competition: 2004 Stage 1, Senior #3</h5>
<p>A spreadsheet consists of a number of "cells" set in a rectangular grid. Each is addressed with one letter from \(A\) to \(J\) (giving the row) and one number from \(1\) to \(9\) (giving the column). Thus the upper-left cell of the spreadsheet is \(A1\), and the lower-right cell is \(J9\).</p>
<p>Every cell has a value, and this can be specified in one of two ways:</p>
<ol>
<li>as an integer from \(0\) to 1000</li>
<li>as a...CCC '04 S2 - TopYodeller2017-09-02T17:02:12+00:002017-09-02T17:02:12+00:00https://dmoj.ca/problem/ccc04s2<div><h5>Canadian Computing Competition: 2004 Stage 1, Senior #2</h5>
<p>A yodel is a wordless song that shifts suddenly from a normal voice to a high, falsetto voice and back. Yodeling, present in many Swiss folk songs, is commonly heard throughout the Alps.</p>
<p>The TopYodeller contest invites the worldâ€™s best yodellers to compete for a share of 100,000 Swiss Francs, with the best yodeller receiving 50,000 Francs. Each yodeller competes in a series of yodel rounds, and is assigned a score, b...APIO '10 P3 - Signaling2017-09-01T13:06:22+00:002017-09-01T13:06:22+00:00https://dmoj.ca/problem/apio10p3<div><p>A telecom company is developing a GSM network in the city of Beijing.
There are \(n\) houses in the city that need to be covered by the network. Due
to budget constraints, the company can install only a single antenna.</p>
<p>To simplify the placement of this antenna, the location will be determined
by picking 3 of the \(n\) houses to make a circle and then placing the antenna at
the center of this circle. The range of the antenna will be such that all houses
that lie within this circle,...APIO '10 P2 - Patrol2017-08-26T16:12:31+00:002017-08-26T16:12:31+00:00https://dmoj.ca/problem/apio10p2<div><p>In a city, there are \(N\) villages numbered \(1, 2, \ldots, N\) . There are \(N âˆ’ 1\) roads connecting them. Each road connects exactly \(2\) villages, and from any village, one can reach any other village using these roads. The length of each road is \(1\) unit.</p>
<p>To ensure safety of the people in the city, each day a city police patrol has to travel on every road. The police station is at village \(1\), so the patrol has to start from village 1 and finally return to village \(1\)...APIO '10 P1 - Commando2017-08-26T16:02:31+00:002017-08-26T16:02:31+00:00https://dmoj.ca/problem/apio10p1<div><p>You are the commander of a troop of \(n\) soldiers, numbered from \(1\) to \(n\). For the battle ahead, you plan to divide these \(n\) soldiers into several commando units. To promote unity and boost morale, each unit will consist of a contiguous sequence of soldiers of the form \((i, i+1, . . . , i+k)\).</p>
<p>Each soldier \(i\) has a battle effectiveness rating \(x_i\). Originally, the battle effectiveness \(x\) of a commando unit \((i, i+1, . . . , i+k)\) was computed by adding up th...IOI '10 P6 - Traffic Congestion2017-08-20T17:40:00+00:002017-08-20T17:40:00+00:00https://dmoj.ca/problem/ioi10p6<div><p><img src="https://dmoj.ml/data/ioi/10/ioi10p6.1.jpg" alt="Gridlock" style="float:right;height:300px;margin-left:5px;"></p>
<p>Although Canada is a large country, many areas are uninhabited, and most of the population lives near the southern border. The Trans-Canada Highway, completed in 1962, connects the people living in this strip of land, from St. John's in the East to Victoria in the West, a distance of 7821 km.</p>
<p>Canadians like hockey. After a hockey game, thousands of fans get...A Harder Game2017-08-19T21:38:33+00:002017-08-19T21:38:33+00:00https://dmoj.ca/problem/ahardergame<div><p>You are playing a game with Bruce involving \(N\) coins laid out in a row.</p>
<p>The two players alternate taking coins from either end of the row. The game ends when no more coins remain.</p>
<p>Bruce is a genius and will always play optimally. However, he is nice and will let you make the first move. What is the maximum total value of coins you can take?</p>
<h4>Input Specification</h4>
<p>The first line will contain \(N\), the number of coins.<br>
The second and final line of input w...IOI '10 P5 - Memory2017-08-19T00:57:00+00:002017-08-19T00:57:00+00:00https://dmoj.ca/problem/ioi10p5<div><p><img src="https://dmoj.ml/data/ioi/10/ioi10p5.jpg" style="float:right;height:300px;margin-left:5px;"></p>
<p>A game called <em>Memory</em> is played using \(50\) cards. Each card has one of the letters from <code>A</code> to <code>Y</code> (ASCII 65 to 89) printed on the face, so that each letter appears on exactly two cards. The cards are shuffled into some random order and dealt face down on the table.</p>
<p>Jack plays the game by turning two cards face up so the letters are visible. ...IOI '10 P3 - Quality of Living2017-08-19T00:10:00+00:002017-08-19T00:10:00+00:00https://dmoj.ca/problem/ioi10p3<div><p><img src="https://dmoj.ml/data/ioi/10/ioi10p3.jpg" alt="CatfishCoffeeStreetSign" style="float:right;height:300px;margin-left:5px;"></p>
<p>Cities in Alberta tend to be laid out as rectangular grids of blocks. Blocks are labeled with coordinates \(0\) to \(R-1\) from north to south and \(0\) to \(C-1\) from west to east.</p>
<p>The quality of living in each particular block has been ranked by a distinct number, called quality rank, between \(1\) and \(R \cdot C\), where \(1\) is the best ...IOI '10 P2 - Hotter Colder2017-08-18T23:10:00+00:002017-08-18T23:10:00+00:00https://dmoj.ca/problem/ioi10p2<html><head>
<style>
.chart {
border-collapse: collapse;
}
.chart td, .chart th {
border: 1px solid black;
padding: 0 5px;
}
.mid {
text-align: center;
}</style></head><body><div style="float:right;margin-left:5px;">
<img src="https://dmoj.ml/data/ioi/10/ioi10p2.jpg" alt="Heat"></div><p>Jack and Jill play a game called <em>Hotter, Colder</em>. Jill has a number between \(1\) and \(N\), and Jack makes repeated attempts to guess it.</p>
<p>Each of Jack's guesses is a number between \(1\)...IOI '10 P1 - Cluedo2017-08-12T19:25:00+00:002017-08-12T19:25:00+00:00https://dmoj.ca/problem/ioi10p1<html><head>
<style>
.cen-td td {
text-align: center;
}
.cen-th td {
padding-left: 5px;
}
.cen-th th {
text-align: center;
}
.cen-td td, .cen-th, .cen-th th {
border: 1px solid black;
}</style></head><body><p>Dr. Black has been murdered. Detective Jill must determine the murderer, the location, and the weapon. There are six possible murderers, numbered \(1\) to \(6\). There are ten possible locations, numbered \(1\) to \(10\). There are six possible weapons, numbered \(1\) to \(6\).</p>
...COCI '08 Contest 6 #6 Slicice2017-08-09T01:29:14+00:002017-08-09T01:29:14+00:00https://dmoj.ca/problem/coci08c6p6<div><p>After their pool burst, Mirko and Slavko started collecting cards. In their neighbourhood, card
collection is taken seriously and there are strict rules for the purchase and trading of cards.</p>
<p>Purchasing cards is <strong>always</strong> done by two children together. Each of them gives half the required funds
and <strong>two</strong> cards are bought. Then they race to the fountain downtown, the winner getting both cards. If
they arrive at the exact same time, each of them gets one...COCI '08 Contest 6 #5 Dostava2017-08-09T00:13:07+00:002017-08-09T00:13:07+00:00https://dmoj.ca/problem/coci08c6p5<div><p>Little Ivica recently got a job delivering pizzas for the most popular pizzeria in town.</p>
<p>At the start of his work day, he receives a list with the locations to which he needs to deliver pizzas, <strong>in
order</strong> in which the locations are given.</p>
<p>The city is divided into \(R\times C\) cells. The rows are numbered \(1\) through \(R\), columns \(1\) through \(C\).
From every cell, it is possible to move to neighbouring cells to the left and right. Moving up or down is
...