Recently Added OlympiadsOJ Problemshttps://oj.olympiads.ca/2020-04-07T00:38:42+00:00The latest problems added on the Olympiads Online Judge | DMOJ websiteJS Minification2020-04-07T00:38:42+00:002020-04-07T00:38:42+00:00https://oj.olympiads.ca/problem/neerc2018j<div><p>International Coding Procedures Company (ICPC) writes all its code in Jedi Script (JS) programming language. JS does not get compiled, but is delivered for execution in its source form. Sources contain comments, extra whitespace (including trailing and leading spaces), and other non-essential features that make them quite large but do not contribute to the semantics of the code, so the process of <u>minification</u> is performed on source files before their delivery to execution to compr...COCI '19 Contest 6 #5 Trener2020-04-06T04:14:56+00:002020-04-06T04:14:56+00:00https://oj.olympiads.ca/problem/coci19c6p5<div><p>At this point we already know that students love to sleep. Patrik is a
record holder in this category. He wakes up only when he needs to eat
or if he wishes to play <em>FIFA 20</em>. Therefore, his dreams usually revolve
around football. In his last dream, he found himself in the role of a football
manager of his favourite team – GNK Dinamo Zagreb.</p>
<p>His job is to select \(N\) players that will defend the blue colors in the next
season, but the board has some peculiar requests. They...COCI '19 Contest 6 #1 Datum2020-04-06T04:09:47+00:002020-04-06T04:09:47+00:00https://oj.olympiads.ca/problem/coci19c6p1<div><p>The exam season at University of Zagreb is over and students are doing what
they love the most – sleeping. In the rare moments of wakefulness, they usually
scroll over their Instagram feed. Fabijan is one of those students.</p>
<p>Recently, he read the following caption – the date <code>02.02.2020</code>. is the first
palindromic date in the last \(909\) years.</p>
<p>He realized the caption was incorrect and this made him wonder about palindromic dates so he asked himself for each of th...COCI '19 Contest 4 #4 Klasika2020-04-06T04:00:25+00:002020-04-06T04:00:25+00:00https://oj.olympiads.ca/problem/coci19c4p4<div><p>In the beginning there was a node denoted as \(1\) and it represented the root of a tree. Your task is to
support \(Q\) queries of the form:</p>
<p>• Add <code>x y</code> – Adds a new node to the tree as a child of node \(x\). The newly added node and node \(x\) are
connected with an edge of weight \(y\). The newly added node is denoted by a number equal to the
number of nodes that the tree consists of after its addition.</p>
<p>• Query <code>a b</code> – Finds the longest path in a tree...COCI '19 Contest 4 #3 Holding2020-04-06T03:51:54+00:002020-04-06T03:51:54+00:00https://oj.olympiads.ca/problem/coci19c4p3<div><p>Difficult times lie ahead of Ivica and his Holding – a group of \(N\) Croatian companies
that are in his ownership. Each of these companies is in debt so the state sent its
attorneys to take everything away from him. We have exclusively found out that
Ivica managed to make a deal with the state to leave him certain companies in spite
of the massive debt. Which ones? We found that out as well.</p>
<p>The state attorneys have laid out \(N\) proprietary papers of Ivica's companies on the
ta...COCI '19 Contest 4 #2 Spiderman2020-04-06T03:45:27+00:002020-04-06T03:45:27+00:00https://oj.olympiads.ca/problem/coci19c4p2<div><p>Little Ivan likes to play <strong>Yamb</strong> and read Marvel superhero comics. His
favorite superhero is spider-man, a friendly neighbourhood teenager named
Peter Parker who got his superpowers via a radioactive spider bite. Ivan
fantasizes that one day he will be able to jump from one skyscraper to
another, just like spider-man does in the comics. During one such fantasy,
he fell asleep.</p>
<p>In his dream he was no longer named Ivan, his name was Peter Parkour and,
you guessed it, ...COCI '19 Contest 3 #5 Sob2020-04-06T03:11:47+00:002020-04-06T03:11:47+00:00https://oj.olympiads.ca/problem/coci19c3p5<div><p>It was a dark and dreary Christmas Eve when our hero pondered, weak and weary,
over a quaint and curious COCI task. When he nodded, nearly napping, suddenly
he heard a tapping, tapping and a mighty roar. A giant reindeer broke through his
chamber door, merely this and nothing more. While our hero’s heart slightly fluttered,
the beast simply uttered: <em>"I won’t leave until you solve this problem"</em>.</p>
<p>In the problem you were given two integers \(N\) and \(M\) and you were suppos...COCI '19 Contest 3 #4 Lampice2020-04-06T02:46:23+00:002020-04-06T02:46:23+00:00https://oj.olympiads.ca/problem/coci19c3p4<div><p>Mirko chose a Christmas tree for the upcoming holidays and decided to decorate it
with Christmas lights. Christmas lights contain \(N\) LED lights that are connected
via \((N − 1)\) conductive wires such that all of the lights are connected. Additionally,
we know the color of each Christmas light.</p>
<p>After he decorated the tree, Mirko proudly stared at his masterpiece. After a while,
he started noticing different patterns. Among those patterns, he was particularly
amazed by so-called...COCI '19 Contest 3 #1 Preokret2020-04-06T02:32:37+00:002020-04-06T02:32:37+00:00https://oj.olympiads.ca/problem/coci19c3p1<div><p>It's <em>Saint Stephen's Day</em>, the day after Christmas. The secular version of the same
holiday in England is known as <em>Boxing day</em>. While people in Croatia celebrate
Saint Stephen’s Day by stuffing themselves with ridiculous amounts of food, our
British friends traditionally play football. Premier league, Championship, amateur
leagues – everybody plays football on Boxing day.</p>
<p>This year, Pep ate too much roast beef on Christmas and decided to take a break
from Boxing da...COCI '19 Contest 1 #5 Zoo2020-04-06T02:25:07+00:002020-04-06T02:25:07+00:00https://oj.olympiads.ca/problem/coci19c1p5<div><p>On a cold Christmas night in 2010, Zagreb was covered in snow. Zdravko decided
to leave his castle, cross the road and take a stroll through the Maksimir park.
Unfortunately, the idyllic winter evening was interrupted by a monster that
was lurking in the nearby bushes. The monster jumped in front of Zdravko, but
Zdravko roared a mighty roar which scared the monster away. Unbeknownst
to him, a bunch of animals from the nearby zoo were startled by that roar.
More precisely, a group of tige...A Wild Goose Chase2020-04-03T21:19:26+00:002020-04-03T21:19:26+00:00https://oj.olympiads.ca/problem/awildgoosechase<div><p>Recently, <span style="color:blue; font-weight:bold">geese</span> was murdered! The city has asked you to help Ducktective to figure out who murdered <span style="color:blue; font-weight:bold">geese</span> given the following information. There are \(N\) foxes numbered from \(1\) to \(N\), suspected to have killed <span style="color:blue; font-weight:bold">geese</span>. Each fox gives <strong>precisely one statement</strong>. A fox either accuses another fox of the murder or say it wasn'...South African Computer Olympiad 2008 Day 1 Problem 3 - Visiting Grandma2020-04-02T22:24:37+00:002020-04-02T22:24:37+00:00https://oj.olympiads.ca/problem/saco08p3<div><p>Bruce plans to visit his beloved grandmother whom he has not seen in ages. The petrol price is high and the roads are dangerous, so he wants to travel the shortest possible distance. He also wants to know how much choice he has for the route, as he wants to visit his grandmother more often and being Bruce, he loves change.</p>
<p>Bruce wants to surprise his grandmother with a box of cookies every time he visits. Bruce does not know how to make real cookies (digital ones are easy, however...UTS Open '15 #5 - Distribution Channel (Hard)2020-03-31T21:32:27+00:002020-03-31T21:32:27+00:00https://oj.olympiads.ca/problem/utso15p5hard<div><div style="max-width: 100%;height: 249;max-height: 249;width: 249;text-align: center"><img src="https://static.dmoj.ca/texoid/00f3eedbca866bd2744181303eea265e473e4918/svg" onerror="this.src='//static.dmoj.ca/texoid/00f3eedbca866bd2744181303eea265e473e4918/png';this.onerror=null" width="851" height="249"></div><div style="text-align:center"><em>Distribution channels are often very confusing.</em></div><p>After acquiring enough funding and finally finishing the development for her product, M...Road Redirection2020-03-30T15:43:08+00:002020-03-30T15:43:08+00:00https://oj.olympiads.ca/problem/roadredirection<div><p>Once upon a time, Nella lived in a peaceful village with \(N\) buildings and \(N-1\) roads, where it was possible to reach any building from any other. One day, a large earthquake struck and directed all the roads! Since communication is extremely important, Nella would like to establish one building as the town hall, where it is possible to reach <strong>any</strong> building from the town hall after redirecting some amount of roads. Even worse for the village is that the roads started ...DMOPC '19 Contest 6 P6 - Math is Difficult2020-03-30T04:53:44+00:002020-03-30T04:53:44+00:00https://oj.olympiads.ca/problem/dmopc19c6p6<div><p>Tzovex is currently taking a course in real analysis. Unfortunately for him and his class, they are having trouble following the lectures and are now struggling with a particular homework assignment that is due in \(D+1\) days. The homework assignment consists of \(M\) questions, the \(i\)th of which has a value of \(v_i\). Including himself, Tzovex's class consists of \(N\) students, the \(j\)th of which having solved the first \(a_j\) problems while being unable to solve the rest. Howe...DMOPC '19 Contest 6 P5 - University Math2020-03-30T04:53:31+00:002020-03-30T04:53:31+00:00https://oj.olympiads.ca/problem/dmopc19c6p5<div><p>It's Jack's first day of freshman year at the University of Fireloo! He looks at his timetable but is disappointed to find that he has to take data management again. Having grown tired of drawing charts, he decides to challenge himself to draw as efficiently as he can!</p>
<p>Today, Jack is trying to draw a histogram! A <a href="https://en.wikipedia.org/wiki/Histogram#/media/File:Travel_time_histogram_total_n_Stata.png" rel="nofollow">histogram</a> consists of \(N\) bars of positive hei...DMOPC '19 Contest 6 P3 - Grade 11 Math2020-03-30T04:53:20+00:002020-03-30T04:53:20+00:00https://oj.olympiads.ca/problem/dmopc19c6p3<div><p>Serena is learning about binary numbers in math class! She is given a binary number \(S\), and she is also given series of \(M\) operations which she must perform on it. In one operation, she sets all bits in the 1-indexed range \([l,r]\) to \(1\), and outputs the base-10 value of the binary number, modulo \(10^9+7\).</p>
<p>The base-10 value of a binary number \(S\) of length \(n\) consisting of digits \(0\) and \(1\) is given by the sum of \(S_i \times 2^{n-i}\) over all \(i\) in \([1,...DMOPC '19 Contest 6 P2 - Grade 10 Math2020-03-30T04:53:15+00:002020-03-30T04:53:15+00:00https://oj.olympiads.ca/problem/dmopc19c6p2<div><p>Counting is very difficult so Veshy asks you for help. You are given two positive integers, \(a\) and \(b\). You want to find the highest power of \(a\), \(n\), that will divide into \(b!\). In other words you want to find the maximum \(n\) such that \(a^n\) divides into \(b!\).</p>
<h4>Input Specification</h4>
<p>The input is a single line containing two space-separated integers, \(a\) and \(b\) in that order. \(1<a<b\le10^6\)</p>
<h4>Output Specification</h4>
<p>Output on a singl...DMOPC '19 Contest 6 P1 - Grade 9 Math2020-03-30T04:53:09+00:002020-03-30T04:53:09+00:00https://oj.olympiads.ca/problem/dmopc19c6p1<div><p>Veshy is struggling in math class so he asks you for help (again). You are given two lines each defined by a pair of distinct points, \((x_1,y_1)\) and \((x_2,y_2)\), \(x_1,y_1,x_2,y_2 \in Z\). You are to find if the two lines are parallel, coincident, or intersecting.</p>
<h4>Input Specifications</h4>
<p>The input will consist of two lines.<br>
The first line of input will consist of four space-separated integers in the following order: \(x_1\), \(y_1\), \(x_2\), \(y_2\), the coordinate...DMOPC '19 Contest 6 P0 - Trivial Math2020-03-30T04:52:59+00:002020-03-30T04:52:59+00:00https://oj.olympiads.ca/problem/dmopc19c6p0<div><p>You are given three positive integers, \(a, b, c\), such that \(a,b,c\le1 \space 000 \space 000\). Determine whether a triangle of non-zero area can be formed with \(a, b\), and \(c\) as side lengths.</p>
<h4>Input Specifications</h4>
<p>The input consists of a single line with integers \(a, b, c\) separated by spaces.</p>
<h4>Output Specifications</h4>
<p>Output on a single line, <code>yes</code> if a valid triangle can be formed.<br>
If a valid triangle can not be formed, output <code>...Modulo Sort2020-03-28T20:39:06+00:002020-03-28T20:39:06+00:00https://oj.olympiads.ca/problem/modulosort<div><p>Given an array of non-negative integers \(M\) and positive integer \(K\), sort the elements of the given array in the increasing order of their modulo with \(K\). If two or more elements have the same remainder, sort the numbers numerically.</p>
<h4>Input Specifications</h4>
<p>You will receive three lines of input. The first line will contain positive integer \(N\) (\(1 ≤ N ≤ 10^5\)), the length of the array.</p>
<p>The next line will contain positive integer \(K\) (\(1 ≤ K ≤ 10^7\)), t...Angie and Functions (Hard)2020-03-28T19:40:13+00:002020-03-28T19:40:13+00:00https://oj.olympiads.ca/problem/functions<div><p>Angie is studying functions!</p>
<p>For her homework, she was asked to figure out the coefficients \(c_1, c_2, ..., c_N, c_{N+1}\) in the following function:</p>
<blockquote><p>\(f(x)=c_1x^N+c_2x^{N-1}+...+c_Nx+c_{N+1}\) (All the coefficients are integers)</p>
</blockquote>
<p>Angie has \(N + 1\) arbitrary integer \((x, y)\) coordinate pairs on the polynomial, and wants you to help her find the coefficients.</p>
<p>Can you help her?</p>
<h4>Input Specification</h4>
<p>The first line of i...CCC '20 S2 - Escape Room2020-03-25T20:09:10+00:002020-03-25T20:09:10+00:00https://oj.olympiads.ca/problem/ccc20s2<div><h5>Canadian Computing Competition: 2020 Stage 1, Junior #5, Senior #2</h5>
<p>You have to determine if it is possible to escape from a room. The room is an \(M\)-by-\(N\) grid with each position (cell) containing a positive integer. The rows are numbered \(1,2,\dots,M\) and the columns are numbered \(1,2,\dots,N\). We use \((r,c)\) to refer to the cell in row \(r\) and column \(c\).</p>
<p>You start in the top-left corner at \((1,1)\) and exit from the bottom-right corner at \((M,N)\). If ...CCC '20 S1 - Surmising a Sprinter’s Speed2020-03-25T19:31:31+00:002020-03-25T19:31:31+00:00https://oj.olympiads.ca/problem/ccc20s1<div><h5>Canadian Computing Competition: 2020 Stage 1, Senior #1</h5>
<p>Trick E. Dingo is trying, as usual, to catch his nemesis the Street Sprinter. His past attempts using magnets, traps and explosives have failed miserably, so he’s catching his breath to gather observational data and learn more about how fast Street Sprinter is.</p>
<p>Trick E. Dingo and Street Sprinter both inhabit a single straight west-east road with a particularly famous rock on it known affectionately as The Origin. Pos...CCC '20 J4 - Cyclic Shifts2020-03-25T19:30:29+00:002020-03-25T19:30:29+00:00https://oj.olympiads.ca/problem/ccc20j4<div><h5>Canadian Computing Competition: 2020 Stage 1, Junior #4</h5>
<p>Thuc likes finding cyclic shifts of strings. A <em>cyclic shift</em> of a string is obtained by moving characters from the beginning of the string to the end of the string. We also consider a string to be a cyclic shift of itself. For example, the cyclic shifts of <code>ABCDE</code> are:</p>
<center><code>ABCDE</code>, <code>BCDEA</code>, <code>CDEAB</code>, <code>DEABC</code>, and <code>EABCD</code>.</center><p>Given some ...