Irish Collegiate Programming Contest Problem Set

Similar documents
Homework Assignment #1

Problem F. Chessboard Coloring

2013 ACM ICPC Southeast USA Regional Programming Contest. 2 November, Division 1

Episode 5 11 th 14 th May Casual & Word by Rakesh Rai

Lower Fall Programming Contest 2017

VMO Competition #1: November 21 st, 2014 Math Relays Problems

IN THIS ISSUE. Cave vs. Pentagroups

UTD Programming Contest for High School Students April 1st, 2017

2014 ACM ICPC Southeast USA Regional Programming Contest. 15 November, Division 1

LMI-MONTHLY TEST JUN 2010 'SPEED SIXES'

Episode 3 16 th 19 th March Made In India and Regions by Prasanna Seshadri

Eleventh Annual Ohio Wesleyan University Programming Contest April 1, 2017 Rules: 1. There are six questions to be completed in four hours. 2.

The Eighth Annual Student Programming Contest. of the CCSC Southeastern Region. Saturday, November 3, :00 A.M. 12:00 P.M.

2015 ACM ICPC Southeast USA Regional Programming Contest. Division 1

WPF PUZZLE GP 2018 ROUND 1 COMPETITION BOOKLET. Host Country: Turkey. Serkan Yürekli, Salih Alan, Fatih Kamer Anda, Murat Can Tonta A B H G A B I H

WPF PUZZLE GP 2018 ROUND 3 COMPETITION BOOKLET. Host Country: India + = 2 = = 18 = = = = = =

UW-Madison ACM ICPC Individual Contest

Twenty-fourth Annual UNC Math Contest Final Round Solutions Jan 2016 [(3!)!] 4

B1 Problem Statement Unit Pricing

The 2009 British Informatics Olympiad

BALDWIN WALLACE UNIVERSITY 2013 PROGRAMMING CONTEST

A few chessboards pieces: 2 for each student, to play the role of knights.

ACM ICPC World Finals Warmup 2 At UVa Online Judge. 7 th May 2011 You get 14 Pages 10 Problems & 300 Minutes

A1 Problem Statement Unit Pricing

2008 High School Math Contest Draft #3

Grade 6 Math Circles March 7/8, Magic and Latin Squares

1. Hex Tapa (12 points) 2. Hex Dominos (13 points)

KenKen Strategies. Solution: To answer this, build the 6 6 table of values of the form ab 2 with a {1, 2, 3, 4, 5, 6}

LMI Monthly Test May 2010 Instruction Booklet

Problem A. Jumbled Compass

Welcome to the Sudoku and Kakuro Help File.

Swaroop Guggilam, Ashish Kumar, Rajesh Kumar, Rakesh Rai, Prasanna Seshadri


What is the sum of the positive integer factors of 12?

WPF PUZZLE GP 2016 ROUND 8 INSTRUCTION BOOKLET. Host Country: Russia. Andrey Bogdanov. Special Notes: No special notes for this round.

NX 7.5. Table of Contents. Lesson 3 More Features

Vocabulary slope, parallel, perpendicular, reciprocal, negative reciprocal, horizontal, vertical, rise, run (earlier grades)

Problem C The Stern-Brocot Number System Input: standard input Output: standard output

Using KenKen to Build Reasoning Skills 1

2008 Canadian Computing Competition: Senior Division. Sponsor:

Organization Team Team ID# If each of the congruent figures has area 1, what is the area of the square?

WPF PUZZLE GP 2019 ROUND 3 INSTRUCTION BOOKLET. Host Country: Serbia. Čedomir Milanović, Zoran Tanasić, Nikola Živanović NOMNONMON B NOMNONMON

Part III F F J M. Name

LMI SUDOKU TEST 7X JULY 2014 BY RICHARD STOLK

Logic Masters India Presents

2. Nine points are distributed around a circle in such a way that when all ( )

Indian Sudoku Championship 2015

Sponsored by IBM. 2. All programs will be re-compiled prior to testing with the judges data.

Problem A. Ancient Keyboard

SGU 149. Computer Network. time limit per test: 0.50 sec. memory limit per test: 4096 KB input: standard input output: standard output

Senior Math Circles February 10, 2010 Game Theory II

UK JUNIOR MATHEMATICAL CHALLENGE. April 25th 2013 EXTENDED SOLUTIONS

NRP Math Challenge Club

The patterns considered here are black and white and represented by a rectangular grid of cells. Here is a typical pattern: [Redundant]

SolidWorks 95 User s Guide

1999 Mathcounts National Sprint Round Solutions

BAPC The Problem Set

SENIOR DIVISION COMPETITION PAPER

Final Practice Problems: Dynamic Programming and Max Flow Problems (I) Dynamic Programming Practice Problems

constant EXAMPLE #4:

1 Introduction. 2 An Easy Start. KenKen. Charlotte Teachers Institute, 2015

Unhappy with the poor health of his cows, Farmer John enrolls them in an assortment of different physical fitness activities.

Problem Darts Input File: DartsIn.txt Output File: DartsOut.txt Project File: Darts

BRITISH COLUMBIA SECONDARY SCHOOL MATHEMATICS CONTEST, 2006 Senior Preliminary Round Problems & Solutions

In the game of Chess a queen can move any number of spaces in any linear direction: horizontally, vertically, or along a diagonal.

Episode 5 26 th 28 th December

BMT 2018 Combinatorics Test Solutions March 18, 2018

Problem A: Complex intersecting line segments

March 5, What is the area (in square units) of the region in the first quadrant defined by 18 x + y 20?

CPSC 217 Assignment 3 Due Date: Friday March 30, 2018 at 11:59pm

2008 ACM ICPC Southeast USA Regional Programming Contest. 25 October, 2008 PROBLEMS

State Math Contest (Junior)

Spring 06 Assignment 2: Constraint Satisfaction Problems

Counting in Algorithms

Math Labs. Activity 1: Rectangles and Rectangular Prisms Using Coordinates. Procedure

Problems. High School Programming Tournament. acm. YnE. Seventh Annual University of Central Florida

UKPA Presents. March 12 13, 2011 INSTRUCTION BOOKLET.

UK Puzzle Association Sudoku Championship 2012 All puzzles by Gareth Moore

Exploring Concepts with Cubes. A resource book

1. Open the Feature Modeling demo part file on the EEIC website. Ask student about which constraints needed to Fully Define.

WPF PUZZLE GP 2018 ROUND 4 COMPETITION BOOKLET. Host Country: Czech Republic

BmMT 2015 Puzzle Round November 7, 2015

Level 4 KS3 Answers 1. Completes all three grids correctly, ie 3

1 Recursive Solvers. Computational Problem Solving Michael H. Goldwasser Saint Louis University Tuesday, 23 September 2014

WPF PUZZLE GP 2018 ROUND 2 INSTRUCTION BOOKLET. Host Country: Switzerland. Markus Roth, Roger Kohler, Esther Naef

UCF Local Contest September 3, 2016

Self Learning Game Software Requirements Specification Joint Document Version 1

Indian Puzzle Championship 2013

WPF PUZZLE GP 2018 ROUND 2. COMPETITION BOOKLET Host Country: Switzerland. ScHWeIZ. ScHWeiz. schweiz. SchWEIZ. SchwEiz. SchWEiZ. schweiz.

Synergy Round. Warming Up. Where in the World? Scrabble With Numbers. Earning a Gold Star

Evaluation Chapter by CADArtifex

Do not open this exam until told to do so.

Lesson 1b Linear Equations

Junior Questions: Part A

Mathematical J o u r n e y s. Departure Points

< Then click on this icon on the vertical tool bar that pops up on the left side.

14th Bay Area Mathematical Olympiad. BAMO Exam. February 28, Problems with Solutions

Problem Solving for Irish Second level Mathematicians. Senior Level. Time allowed: 60 minutes. Rules and Guidelines for Contestants

UKMT UKMT. Team Maths Challenge 2015 Regional Final. Group Round UKMT. Instructions

Math 1111 Math Exam Study Guide

Transcription:

Irish Collegiate Programming Contest 2011 Problem Set University College Cork ACM Student Chapter March 26, 2011 Contents Instructions 2 Rules........................................... 2 Testing and Scoring.................................... 2 Submission Instructions................................. 3 1 Emirps 4 2 Base Addition 5 3 Postfix 6 4 Knights 7 5 Frame Stacking 8 6 Jugs 10 7 Kakuro 12 8 Problem of Apollonius 15 1

Instructions Rules Once the contest begins teams may not confer with any other person, including their coach. All mobile phones, laptops and other electronic devices must be powered off and stored away for the duration of the contest. Teams may confer privately in one of the supervised spaces outside the labs. Please let an organiser know if you need to do this. The only networked resource that teams are permitted to access is the submission system. If a team discovers an ambiguity or error in a problem statement they should tell an organiser. If the organisers agree that an ambiguity or error exists, a clarification will be issued to all teams. Testing and Scoring When teams submit a solution the submission time will be recorded and the solution will be queued for testing. A problem will be tested against 10 test cases, the first two of which are given to you on problem sheet. A solution will be accepted if it compiles on the test environment. If a solution is submitted while an earlier solution to the same problem is still in the queue, the earlier submission will not be tested. The earlier submission will be marked with the message: Old, not going to be tested. All accepted problems will be scored out of 10 points, one for each test case that returns the correct output. You will not be told the points scored until the end of the contest. In the event of a tie on points, the winning team will be the one with the shortest amount of time between the contest start and their last solution that increased their score. Page 2

Submission Instructions The submission system URL is: http://4c128.ucc.ie/ Your password will be provided by the organisers. unable to log in. Please notify an organiser if you Submissions should consist of a single source file. To submit, click the Submit a Solution link, complete the submission form, upload your source file, and click save. Your submission should now be listed in your submission queue. Submission input is read from standard input and submission output should be written to standard output. To teams submitting Java solutions, be aware the testing script will be renaming your file to Pn.java (where n is the problem number) and as such the main class for problem 1 would be defined as: public class P1 {... } and will be called by : java P1 < input-file Page 3

1 Emirps Task An emirp is a prime number that is also prime when its digits are reversed, and that is also not a palindrome. For instance, 13 is an emirp because its reversal, 31, is also prime; 23 is not an emirp, even though it is prime, because its reversal, 32, is not prime; and 101 is not an emirp, even though it is prime, because it is a palindrome. Given two numbers N and M, your task is to find the list of emirps that occur between N and M inclusive. Input Two numbers N and M ( 0 < N < M < 1,000,000 ) on the same line separated by a space, followed by a newline. Output A space separated list of emirps between N and M inclusive, followed by a newline. Sample Input Two separate sample cases: 1 20 50 80 Sample Output The corresponding sample output: 13 17 71 73 79 Page 4

2 Base Addition Task People are more familiar with addition in the decimal (base 10) numeral system, but addition is possible in number systems of any base, including binary (base 2), octal (base 8) and hexadecimal (base 16). Given 3 numbers, s1, s2, s3, where the numeral system is not specified, the expression s1 + s2 = s3 may be correct in some numeral systems, but not in others. Input Input is 3 strings s1, s2, s3 separated by spaces. These strings represent numbers in an unknown numeral system (unknown base). Each string will be at most 20 characters, and will consist of digits & upper-case letters with ASCII value ordering (0, 1, 2, 3,..., Y, Z). Output Output is a single integer x, where x <= 32. x is the smallest base for which the expression s1 + s2 = s3 is true. If no answer exists, print No solution. Sample Input Two separate sample cases: 5 3 10 5 3 7 Sample Output The corresponding sample output: 8 No solution Page 5

3 Postfix Task Postfix expressions are arithmetical expressions where the operators come after anything they operate on. Postfix is important because it maintains precedence without the use of brackets. An example of a postfix expression would be: 3 5 * This would be evaluated as 3 * 5 resulting in an answer of 15. 6 4 * 2 + This would be evaluated as 2 + (6 * 4) resulting in an answer of 22. Input Input will contain a postfix expression which will be no more than 80 characters in length followed by a newline and will contain one expression to be evaluated. All expressions will be correct postfix expressions. There will be one space between each number/operator. The only operators we re interested in is + (addition), - (subtraction), and * (multiplication). There is no division. All numbers are non-negative integers. Output Your program is to output the result of evaluting the expression. Note that while the input numbers will not be negative, the answer may be negative. Sample Input Two separate sample cases: 3 5 * 6 4 * 2 + Sample Output The corresponding sample output: 15 26 Page 6

4 Knights Task In chess, a knight (the horsehead piece) moves differently than any other piece. It moves in an L-type shape. That is, it can move two squares in one direction, then one square in the perpendicular direction (knights can not move diagonally). As an example, consider this:................... *. *.... *... *..... K..... *... *.... *. *.......... The knight is in the square marked by a K. The * around it are the possible positions the knight can move on the next turn. The. are empty squares. If you place two knights on the board, things get a little more complicated. We say that a knight can not be taken if there is not a knight that can land on it s square on the next turn. This condition has to hold regardless of what order the knights move (ie, the knights can t move out of the way). Input Two integers, M, N, separated by exactly one space. The chessboard has size M x M. We re interested in placing N knights on the board such that no knight can take any other knight. The number of knights will be in the range 1 to 36 (inclusive). M will be in the range 1 to 6 (inclusive). Output Your program should print out the number of ways that we can place N knights on an M x M chessboard. The answer will always fit in an unsigned, 32 bit integer. Sample Input Two separate sample cases: 2 2 6 4 Sample Output The corresponding sample output: 6 26133 Page 7

5 Frame Stacking Task Consider the following 3 frames placed on an 5x5 grid. MMMMM NNN..... M...M N.N..... M...M NNN....PPP M...M.....P.P MMMMM.....PPP If the frames are placed top of one another starting with M at the bottom, N in the middle and ending with P on top, any part of a frame covers another it hides that part of the frame below. NNNMM N.N.M NNPPP M.P.P MMPPP The problem is to determine the order in which the frames are stacked from bottom to top given the stacked frames, given the following constraints: The width of the frame is always exactly 1 character and the sides are never shorter than 3 characters. It is possible to see at least one part of each of the four sides of a frame. A corner shows two sides. The frames will be lettered with capital letters, and no two frames will be assigned the same letter. There will be a unique solution to each stack. Input The first line of input contains two integers, the height (h) and width (w) of the grid, separated by a space. The maximum size of the grid will be 30x30. This is followed by h lines of length w. Each character of each line will be a capital letter representing a visible part of a frame, or a full stop if no frame covers that part of the grid. Output A single line, containing the letters of the frames in the order they were stacked from bottom to top. Page 8

Sample Input Two separate sample cases: 9 8.CCC... ECBCBB.. DCBCDB.. DCCC.B.. D.B.ABAA D.BBBB.A DDDDAD.A E...AAAA EEEEEE.. 5 5 NNNMM N.N.M NNPPP M.P.P MMPPP Sample Output The corresponding sample output: EDABC MNP Page 9

6 Jugs Task You have two jugs, A and B, and an infinite supply of water. There are three types of actions that you can use: (1) you can fill a jug, (2) you can empty a jug, and (3) you can pour from one jug to the other. Pouring from one jug to the other stops when the first jug is empty or the second jug is full, whichever comes first. For example, if A contains 5 litres of water and B contains 6 litres of water and has a capacity of 8, then pouring from A to B leaves B full and 3 litres in A. A problem is given by a triple (Ca,Cb,N), where Ca and Cb are the capacities of the jugs A and B, respectively, and N is the goal. A solution is a sequence of steps that leaves exactly N litres of water in jug B. The possible steps are fill A fill B empty A empty B pour A B pour B A success where "pour A B" means "pour the contents of jug A into jug B", and "success" means that the goal has been accomplished. You may assume that the input you are given does have a solution. Input A single line of three positive integers Ca, Cb, and N, separated by spaces. Ca and Cb are the capacities of jugs A and B, and N is the goal. You can assume 0 < Ca <= Cb and N <= Cb and that A and B are relatively prime to one another. Output Output from your program will consist of a series of instructions from the list of the potential output lines which will result in jug B containing exactly N litres of water. The last line of output should be the line success. Page 10

Sample Input Two separate sample cases: 3 5 4 5 7 3 Sample Output The corresponding sample output: fill B pour B A empty A pour B A fill B pour B A success fill A pour A B fill A pour A B empty B pour A B success Page 11

7 Kakuro Task Kakuro, or Cross Sums, is a puzzle played on a grid of filled and empty cells, "black" and "white" respectively. The grid is divided into entries - lines of white cells - by the black cells. Some black cells contain a diagonal slash from upper-left to lower-right and a number in one or both halves, such that each horizontal entry has a number in the black half-cell to its immediate left and each vertical entry has a number in the black half-cell immediately above it. These numbers, borrowing crossword terminology, are commonly called clue. (a) Unsolved (b) Solved Figure 1: A Kakuro puzzle. The object of the puzzle is to insert a digit from 1 to 9 inclusive into each white cell such that the sum of the numbers in each entry matches the clue associated with it and that no digit is duplicated in any entry. Kakuro puzzles must have a unique solution. Page 12

Input The first line of input contains two integers, the height (h) and width (w) of the grid, separated by a space. The maximum size of the grid is 16x16. The height and width of the grid are not required to be equal. Cells are are numbered from 0 to (h w) 1, counting from left to right, and top to bottom. The second line is a list integers separated by spaces, representing numbers of the black cells, excluding clue cells, in ascending order. Every line that follows contain five integers separated by spaces, begining with the number of a clue cell, followed by the clue for the entry below the cell, the length of the entry below the cell, the clue for the entry to the right of the cell and the length of the entry to the right of the cell. If there is no entry below or to the right of the cell, it is represented by the clue 0 and length 0. Here is the puzzle from Fig. 1 in this format: 6 6 0 1 4 5 6 11 24 30 31 35 2 30 4 0 0 3 16 2 0 0 7 4 2 13 2 10 30 4 0 0 12 0 0 25 4 17 3 2 0 0 18 0 0 11 2 21 4 2 10 2 25 0 0 20 4 32 0 0 8 2 Output Your output should be h lines of w characters, representing the solved puzzle grid. For black cells, including clue cells, print a full stop. For white cells print the value for that cell in the solved puzzle. The solved puzzle from Fig. 1 would be output like this:.....67...1798..38.91..9362...17. Page 13

Sample Input Two separate sample cases: 5 5 0 3 4 8 9 13 14 18 19 20 23 24 1 7 3 0 0 2 13 4 0 0 5 0 0 4 2 10 0 0 3 2 15 0 0 6 2 21 0 0 7 1 6 6 0 1 4 5 6 11 24 30 31 35 2 30 4 0 0 3 16 2 0 0 7 4 2 13 2 10 30 4 0 0 12 0 0 25 4 17 3 2 0 0 18 0 0 11 2 21 4 2 10 2 25 0 0 20 4 32 0 0 8 2 Sample Output The corresponding sample output:....13...21...42....7.......67...1798..38.91..9362...17. Page 14

8 Problem of Apollonius Task In Euclidean plane geometry, Apollonius problem is to construct circles that are tangent to three given circles in a plane. Two circles are tangental (only intersecting at one point) are called internally tangent if the areas they enclose intersect, and externally tangent if there is no intersection between the areas they enclose. In Fig. 2 the green circle is externally tangent to the three black circles and the red circle is externally tangent to the three black circles. Figure 2: Externally and internally tangent circles. The aim of this problem is find the circle that is externally tangent to three given circle, or to determine that no such circle exists. Input Input is 3 lines, each containing 3 integers in the range -100 to 100 inclusive, separated by spaces. Each line describes a circle, the first two integers are the x and y coordinates of the centre of the circle, and the third digit is the radius of the circle. Output Output is 3 floating point numbers, rounded to 2 decimal places, and separated by spaces, followed by a newline. The line describes a circle that is externally tangent to the 3 input circles.the first two numbers are the x and y coordinates of the centre of the circle, and the third number is the radius of the circle. If no externally tangent circle exists, output the word none followed by a newline. Page 15

Sample Input Two separate sample cases: 0 0 2 5 0 2 3 3 1 0 0 1 0 1 1 1 0 1 Sample Output The corresponding sample output: 2.50 1.27 0.80 none Page 16