Recently Added DMOJ Problemshttp://139.162.15.171:81/2021-09-07T22:58:15+00:00The latest problems added on the Jetic's Online Judge websiteA plus B Simple2021-09-07T22:58:15+00:002021-09-07T22:58:15+00:00http://139.162.15.171:81/problem/csci120p004<p>In this problem you will be required to calculate the sum of two numbers.</p> <h4>Input Specification</h4> <p>The first line will an integer $$A$$ ($$1 \le A \le 100\,000$$). The second line will another integer $$B$$ ($$1 \le B \le 100\,000$$).</p> <h4>Output Specification</h4> <p>Output 1 line, containing one integer, which is the sum of $$A$$ and $$B$$.</p> <h4>Sample Input 1</h4> <pre><code>1 1</code></pre> <h4>Sample Output 1</h4> <pre><code>2</code></pre> ...Dict Practice 22021-03-10T15:31:09+00:002021-03-10T15:31:09+00:00http://139.162.15.171:81/problem/csci120p002<p>This is the more advanced version of <code>csci120p001</code>.</p> <p>Mr Cleese wants to know how many times a word appears in a sentence. Your task is to help him with it. In addition, the words may not be separated from the punctuation marks. Here's a list of punctuation marks you might encounter: <code>"</code>, <code>'</code>, <code>.</code>, <code>,</code>, <code>:</code>, <code>;</code>, <code>!</code>, <code>?</code></p> <p>These symbols can occur anywhere in the text.</p> <p>(Hint...Dict Practice 12021-03-10T15:29:39+00:002021-03-10T15:29:39+00:00http://139.162.15.171:81/problem/csci120p001<p>Mr Cleese wants to know how many times a word appears in a sentence. Your task is to help him with it.</p> <h4>Input Specification</h4> <p>The first line will contain a single English sentence. All words will be lower case and separated by a single space.</p> <p>The second line will contain a single lowercased word.</p> <h4>Output Specification</h4> <p>The output should contain only integer, the number of times the inquired word has appeared in the sentence.</p> <h4>Sample Input 1</h4> <pre>...Data Structure 42020-07-31T00:30:00+00:002020-07-31T00:30:00+00:00http://139.162.15.171:81/problem/csci125p030<p>Village of the Sorcerer</p> <p>This practice problem will require you to utilise <code>Queue</code> to solve the reachability problem.</p> <p>You are given a map for from the Village of the Sorcerer problems and the player's initial position. Your objective is to print out a map containing all the reachable points for that player.</p> <p>Hint: please make sure you have completed <code>csci125p014</code> before attempting this task.</p> <p>For each step, the player can move in four directions:...Data Structure 32020-07-31T00:30:00+00:002020-07-31T00:30:00+00:00http://139.162.15.171:81/problem/csci125p029<p>This practice problem will require you to implement a simple <code>Queue</code> class, supporting some common functions.</p> <p>The expected header is as follows (<code>p029.h</code>):</p> <pre><code>#ifndef _P029 #define _P029 #include "mylist.h" class Queue { private: MyList list; public: bool empty(); int front(); void push(int val); int pop(); }; #endif</code></pre> <p>Your task is to implement the actual functions for this class. You can u...Data Structure 22020-07-31T00:30:00+00:002020-07-31T00:30:00+00:00http://139.162.15.171:81/problem/csci125p028<p>This practice problem will require you to utilise <code>Stack</code> to solve the bracket matching problem.</p> <p>Brackets are used in many places, and in this task your job is to make sure the three types of brackets are syntactically correct. The rules are very simple, matching pairs of brackets are considered valid.</p> <p>E.g. the following brackets are valid:</p> <pre><code>()[{}] [[]]</code></pre> <p>The following is invalid:</p> <pre><code>[]] ({)}</code></pre> <p>OJ question <code>...Data Structure 12020-07-31T00:30:00+00:002020-07-31T00:30:00+00:00http://139.162.15.171:81/problem/csci125p027<p>This practice problem will require you to implement a simple <code>Stack</code> class, supporting some common functions.</p> <p>The expected header is as follows (<code>p027.h</code>):</p> <pre><code>#ifndef _P027 #define _P027 #include "mylist.h" class Stack { private: MyList list; public: bool empty(); int top(); void push(int val); int pop(); }; #endif</code></pre> <p>Your task is to implement the actual functions for this class. You can use...Class practice 52020-07-19T04:49:35+00:002020-07-19T04:49:35+00:00http://139.162.15.171:81/problem/csci125p026<p>This practice problem will require you to implement a simple list, supporting some common functions.</p> <p>In addition to your work on P025, P026 requires you to add support for <code>del</code> function to the list (removing an element from the list).</p> <p>The expected header is as follows (<code>p026.h</code>):</p> <pre><code>#ifndef _P026 #define _P026 class MyList { int value; MyList* next; MyList* last; public: int length; MyList(); ~MyList(); void prepen...Class practice 42020-07-17T00:30:00+00:002020-07-17T00:30:00+00:00http://139.162.15.171:81/problem/csci125p025<p>This practice problem will require you to implement a simple list, supporting some common functions.</p> <p>The expected header is as follows (<code>p025.h</code>):</p> <pre><code>#ifndef _P025 #define _P025 class MyList { int value; MyList* next; MyList* last; public: int length; MyList(); ~MyList(); void prepend(int val); void append(int val); int get(int ind); int give(int ind, int val); }; #endif</code></pre> <h4>Class Specification</h4> <p><code>...Class practice 3 (Village of the Sorcerer 6)2020-07-10T00:30:00+00:002020-07-10T00:30:00+00:00http://139.162.15.171:81/problem/csci125p024<p>Village of the Sorcerer 6</p> <p>This practice problem will require you to programme basic classes.</p> <p>Please make sure you have passed your OJ practice P014.</p> <p>In this practice problem, we are going to take your implementation of P014, and turn it into an object oriented programming design. We are going to declare a class for handling all our map reading and map outputting operations so that you won't have to struggle with maps anymore.</p> <p>The expected header is as follows:</p> ...Class practice 22020-07-10T00:30:00+00:002020-07-10T00:30:00+00:00http://139.162.15.171:81/problem/csci125p023<p>This practice problem will require you to implement member functions of a class.</p> <p>This question is similar to <code>demo3</code> of handout H804. Given class declaration for <code>CountDown</code>, you are required to implement it's member functions. In addition, you will also need to write your own <code>main.cpp</code> to test your implementation.</p> <p>The header to be used must be called <code>p023.h</code> with the following content:</p> <pre><code>#ifndef _P023 #define _P023 cla...Class practice 12020-07-10T00:30:00+00:002020-07-10T00:30:00+00:00http://139.162.15.171:81/problem/csci125p022<p>This practice problem will require you to implement member functions of a class.</p> <p>Before you get started, please download Handout H804 and find the following files:</p> <pre><code>p022.h demo4.cpp</code></pre> <p>Here, you are required to write <code>p022.cpp</code> and implement member functions in the <code>Circle</code> class in <code>p022.h</code>, just like we did in class.</p> <p>The two member functions:</p> <ol> <li><p><code>void setRadius(double val);</code> should set the pri...String practice 32020-07-07T00:30:00+00:002020-07-07T00:30:00+00:00http://139.162.15.171:81/problem/csci125p021<p>In ancient Rome, the military uses an encryption system to scramble their message so that it's not readable by their enemies.</p> <p>The principle is very simple, for every letter in the message, the Roman officer would replace it with the $$X$$th letter after it in the alphabet.</p> <p>For example, if $$X$$ is 3, then <code>A</code> becomes <code>D</code>, <code>B</code> becomes <code>E</code>, <code>Z</code> becomes <code>C</code>. Given original text:</p> <pre><code>I LIKE CHEESE</code></...String practice 22020-07-07T00:30:00+00:002020-07-07T00:30:00+00:00http://139.162.15.171:81/problem/csci125p020<p>Brackets are used in many places, and in this task your job is to make sure the square brackets are syntactically correct. The rules are very simple, matching pairs of brackets are considered valid.</p> <p>E.g. the following brackets are valid:</p> <pre><code>[] [ [ ] ] [ []]</code></pre> <p>The following is invalid:</p> <pre><code>[] ]</code></pre> <h4>Input Specification</h4> <p>Each line will contain a single test case. Each case will contain no more than 200 characters.</p> <p>There wil...String practice 12020-07-07T00:30:00+00:002020-07-07T00:30:00+00:00http://139.162.15.171:81/problem/csci125p019<p>This practice problem will require you to programme basic string operations.</p> <p>If you are using C++, it is recommended that you use C++ <code>string</code> but C styled Char Array is also fine. If you are using Python, please keep reading.</p> <p>Your task is to compare 2 strings, and figure out if the second string is a substring of the first.</p> <h4>Input Specification</h4> <p>The first line will contain an integer $$N$$ ($$1 &lt; N &lt; 200$$), indicating the number of cases.</p> <p>...Function practice 9 (Village of the Sorcerer 5)2020-06-18T18:35:37+00:002020-06-18T18:35:37+00:00http://139.162.15.171:81/problem/csci125p018<p>Finally, you are assembling the bits you've put together so that the player may move to different areas on the map, but also other maps all together!</p> <p>Hint: please make sure you have completed <code>csci125p014</code>, <code>csci125p015</code>, <code>csci125p016</code>, <code>csci125p017</code> before attempting this task.</p> <p>Remember those houses on the map? Well they aren't just any houses, Mr Cleese wants them to be magical houses: upon entering, the player is transported to anot...Function practice 8 (Village of the Sorcerer 4)2020-06-18T17:41:20+00:002020-06-18T17:41:20+00:00http://139.162.15.171:81/problem/csci125p017<p>Mr Cleese's now wants you to make sure the player doesn't move to places where he isn't supposed to.</p> <p>Hint: please make sure you have completed <code>csci125p014</code>, <code>csci125p016</code> before attempting this task.</p> <p>In addition to the movements in <code>csci125p016</code>, Mr Cleese now wants you to make sure:</p> <pre><code>1. the player doesn't stand on top of the fence. When the player attempts to do so, you must make sure the player remains where he/she is. 2. t...Function practice 7 (Village of the Sorcerer 3)2020-06-18T17:30:09+00:002020-06-18T17:30:09+00:00http://139.162.15.171:81/problem/csci125p016<p>Mr Cleese's other programmer is sick, and now he wants you to implement character movements on the map.</p> <p>Hint: please make sure you have completed <code>csci125p014</code> before attempting this task.</p> <p>Mr Cleese's RPG game has 1 player character, and this player will need to be able to move on the map to explore. Since this chef character designer is still being hired, you can use <code>+</code> sign to denote the character on the map.</p> <p>In addition to the map description in ...Function practice 6 (Village of the Sorcerer 2)2020-06-18T17:10:47+00:002020-06-18T17:10:47+00:00http://139.162.15.171:81/problem/csci125p015<p>Mr Cleese's chef programmer is sick, and since he is so pleased with your work on csci125p014, he has decided to involve you in the further development of his RPG game: a knock-off version of the famous RPG title Tower of the Sorcerer.</p> <p>Hint: please make sure you have completed <code>csci125p014</code> before attempting this task.</p> <p>Mr Cleese's RPG game will have more than one level, each with their individual maps. Aside from what you've done in <code>csci125p014</code>, you will ...Function practice 5 (Village of the Sorcerer 1)2020-06-16T00:24:03+00:002020-06-16T00:24:03+00:00http://139.162.15.171:81/problem/csci125p014<p>This practice problem will require you to programme basic functions.</p> <p>Mr Cleese is designing an RPG game, and he needs someone to help him with the interface.</p> <p>He is going to provide you with a 2 dimensional array describing a map, and your job is to render the map using characters.</p> <p>Each map is represented as a $$N \times M$$ matrix, in which $$N$$ is the height and $$M$$ is the length. Each element in the matrix represents the items in that position. Here's a list of numer...Function practice 42020-06-16T00:22:58+00:002020-06-16T00:22:58+00:00http://139.162.15.171:81/problem/csci125p013<p>This practice problem will require you to programme basic functions.</p> <p>You are required to write a function that calculates the binomial coefficient given input $$n,k$$.</p> <p>$$f(n,k) = \frac{n!}{k!(n-k!)}$$</p> <p>It is recommended that your functions are defined as follows</p> <pre><code>long long factorial(int x); long long binomial(int n, int k);</code></pre> <h4>Input Specification</h4> <p>The first line will contain a 2 integers $$n,k$$ ($$1 &lt; k &lt; n &lt; 20$$).</p> <h4>Out...Function practice 32020-06-16T00:22:02+00:002020-06-16T00:22:02+00:00http://139.162.15.171:81/problem/csci125p012<p>This practice problem will require you to programme basic functions.</p> <p>You are required to write a function that calculates the mean and standard deviation of an array.</p> <p>$$s = \sqrt{\sum^N_{i=1}(x_i-\overline{x})^2 / (N-1)}$$</p> <p>It is recommended that your functions are defined as follows</p> <pre><code>double mean(double a[], int size); double mean(double a[], int size); // size is the total amount of elements in your array a.</code></pre> <h4>Input Specification</h4> <p>The ...Function practice 22020-06-12T00:16:02+00:002020-06-12T00:16:02+00:00http://139.162.15.171:81/problem/csci125p011<p>This practice problem will require you to programme basic functions.</p> <p>Your task is to determine the greatest common divisor (GCD) of two integers.</p> <p>This can be computed using the Euclidean algorithm:</p> <pre><code>func gcd(a, b): // a &gt; b if (b == 0) return a; q = a % b return gcd(b, q)</code></pre> <h4>Input Specification</h4> <p>The first line will contain a single integer $$N$$ ($$1 &lt; N &lt; 10000$$), indicating the number of test cases.</p> <p>The followi...Function practice 12020-06-12T00:04:03+00:002020-06-12T00:04:03+00:00http://139.162.15.171:81/problem/csci125p010<p>This practice problem will require you to programme basic functions.</p> <p>Your task is to determine whether an integer is a palindrome. A palindrome is an integer that reads the same backward as forward, the following are some example palindromes:</p> <pre><code>1 121 5665 22</code></pre> <h4>Input Specification</h4> <p>The first line will contain a single integer $$N$$ ($$1 &lt; N &lt; 10000$$), indicating the number of test cases.</p> <p>The following $$N$$ lines will each contain a sing...Array practice 32020-06-04T19:42:24+00:002020-06-04T19:42:24+00:00http://139.162.15.171:81/problem/csci125p009<p>This practice problem will require you to programme basic array operations.</p> <p>Mr Cleese teaches at the Royal Institute for Monty Python, and he is organising the student president election for this year.</p> <p>The job itself is simple enough: Mr Cleese have $$N$$ students, each with a unique student number from $$1$$ to $$N$$. Each of the students will write down a student number for which they'd like to become the next president. All you have to do is to count which student has the mos...