The 2013 British Informatics Olympiad

Similar documents
The 2017 British Informatics Olympiad

The 2015 British Informatics Olympiad

The 2009 British Informatics Olympiad

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

a b c d e f g h 1 a b c d e f g h C A B B A C C X X C C X X C C A B B A C Diagram 1-2 Square names

Introduction to Spring 2009 Artificial Intelligence Final Exam

For 1 to 4 players Ages 12 to adult. Ternion Factor TM. Three games of strategy Solitaire puzzles. A product of Kadon Enterprises, Inc.

Problem F. Chessboard Coloring

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

GET OVERLAPPED! Author: Huang Yi. Forum thread:

Over ===* Three games of strategy and chance Unique solitaire puzzles. For I to 4 players Ages 12 to adult. PassTM

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25. Homework #1. ( Due: Oct 10 ) Figure 1: The laser game.

Movement of the pieces

arxiv: v2 [cs.ai] 15 Jul 2016

BMT 2018 Combinatorics Test Solutions March 18, 2018

BRITISH GO ASSOCIATION. Tournament rules of play 31/03/2009

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

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

Lesson 8 Tic-Tac-Toe (Noughts and Crosses)

TASK NOP CIJEVI ROBOTI RELJEF. standard output

Problem A To and Fro (Problem appeared in the 2004/2005 Regional Competition in North America East Central.)

CS 32 Puzzles, Games & Algorithms Fall 2013

CPSC 217 Assignment 3

9 X 9 REMOVABLE TYPE ALUMINUM WINDOW BARS INSTALLATION INSTRUCTIONS Import Note : 9 X 9 Spacing Removable Type Installation is covered in this

Das fesselnde Strategiespiel für zwei Personen. The exciting strategy game for two players

Solitaire Games. MATH 171 Freshman Seminar for Mathematics Majors. J. Robert Buchanan. Department of Mathematics. Fall 2010

COCI 2008/2009 Contest #3, 13 th December 2008 TASK PET KEMIJA CROSS MATRICA BST NAJKRACI

Welcome to the Sudoku and Kakuro Help File.

CS61B, Fall 2014 Project #2: Jumping Cubes(version 3) P. N. Hilfinger

For 2 to 6 players / Ages 10 to adult

STAT 430/510 Probability

WPF PUZZLE GP 2018 ROUND 7 INSTRUCTION BOOKLET. Host Country: Netherlands. Bram de Laat. Special Notes: None.

Solutions to Exercises on Page 86

Sudoku goes Classic. Gaming equipment and the common DOMINARI - rule. for 2 players from the age of 8 up

Senior Math Circles February 10, 2010 Game Theory II

CROATIAN OPEN COMPETITION IN INFORMATICS. 7 th ROUND

CMPT 310 Assignment 1

Fractions! You can find much more about all these issues, and more, in the ebook Understanding Fractions [ibooks]. Ronit Bird

Here is a step-by-step guide to playing a basic SCRABBLE game including rules, recommendations and examples of frequently asked questions.

OCTAGON 5 IN 1 GAME SET

2 Textual Input Language. 1.1 Notation. Project #2 2

PLAY AND STRATEGY GUIDE

STAT 430/510 Probability Lecture 1: Counting-1

Upper Primary Division Round 2. Time: 120 minutes

Lines of Action - Wikipedia, the free encyclopedia

Grade 7/8 Math Circles. Visual Group Theory

ACM International Collegiate Programming Contest 2010

Learning the Times Tables!

WHAT IS THIS GAME ABOUT?

ENGR170 Assignment Problem Solving with Recursion Dr Michael M. Marefat

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

Lesson 15: Graphics. Introducing Computer Graphics. Computer Programming is Fun! Pixels. Coordinates

Indian Puzzle Championship 2013

Olympiad Combinatorics. Pranav A. Sriram

GEOGRAPHY PLAYED ON AN N-CYCLE TIMES A 4-CYCLE

How to Build a LimeSurvey: The Basics for Beginners

In how many ways can we paint 6 rooms, choosing from 15 available colors? What if we want all rooms painted with different colors?

Problem A: The Archery Puzzle

9 X 12 REMOVABLE TYPE ALUMINUM WINDOW BARS INSTALLATION INSTRUCTIONS Import Note : 9 X 12 Spacing Removable Type Installation is covered in this

Lab 1. Due: Friday, September 16th at 9:00 AM

The first player to construct his or her obelisk is the winner, and if a player has no legal moves, he or she immediately loses the game.

Assignment 6 Play A Game: Minesweeper or Battleship!!! Due: Sunday, December 3rd, :59pm

Cardinality. Hebrew alphabet). We write S = ℵ 0 and say that S has cardinality aleph null.

Find the items on your list...but first find your list! Overview: Definitions: Setup:

MTAT Systems Modelling. Regular Exam 10 January 2017

Spring 06 Assignment 2: Constraint Satisfaction Problems

Exercises Exercises. 1. List all the permutations of {a, b, c}. 2. How many different permutations are there of the set {a, b, c, d, e, f, g}?

1. Layout all 20 cards face down in 4 rows of This game is played just like Memory or

Creating Your Own PowerPoint Jeopardy Game

GAME GUIDE. The Classic Mystery Game HOW TO PLAY SCARLET WHITE PLUM MUSTARD PEACOCK GREEN

CS1800: More Counting. Professor Kevin Gold

Math Football. Using Models to Understand Integers. Learning Goals. Common Core State Standards for Mathematics. Essential Ideas

Color-matching Non-matching Symmetries Patterns Game

This game can be played in a 3x3 grid (shown in the figure 2.1).The game can be played by two players. There are two options for players:

Mathematics Enhancement Programme TEACHING SUPPORT: Year 3

One Zero One. The binary card game. Players: 2 Ages: 8+ Play Time: 10 minutes

Check out the Weapons. One of these powerful Weapons was used to render the Doctor unconscious for the kidnapping. You must find out which one.


Taffy Tangle. cpsc 231 assignment #5. Due Dates

WORD WINDER Game Play Basics It s As Easy as ABC

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

n r for the number. (n r)!r!

10-1. Combinations. Vocabulary. Lesson. Mental Math. able to compute the number of subsets of size r.

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

Voelzow & Company, Inc.

Exploring Concepts with Cubes. A resource book

Patterns in Fractions

COUNT ON US SECONDARY CHALLENGE STUDENT WORKBOOK GET ENGAGED IN MATHS!

Mathematical Foundations of Computer Science Lecture Outline August 30, 2018

Reinforcing Note Reading in G Position with. by Andrea and Trevor Dow Teach Music Today Learning Solutions

Mind Ninja The Game of Boundless Forms

The Mathematics of Playing Tic Tac Toe

LEO COLOVINI WHO WILL OCCOPY THE MOST PRODUCTIVE PROVINCES?

Game 1 Count em Skill to be learnt What you will need: How to play: Talk points: Extension of this game:

1st Grade Math. Please complete the activity below for the day indicated. Day 1: Double Trouble. Day 2: Greatest Sum. Day 3: Make a Number

Classwork Example 1: Exploring Subtraction with the Integer Game

Problem A. Ancient Keyboard

EXPLORING TIC-TAC-TOE VARIANTS

CPCS 222 Discrete Structures I Counting

2018 NASSC RULES INTRODUCTION

Transcription:

Sponsored by Time allowed: 3 hours The 2013 British Informatics Olympiad Instructions You should write a program for part (a) of each question, and produce written answers to the remaining parts. Programs may be used to help produce the answers to these written questions but are not always necessary. You may use a calculator and the on-line help that your programming language provides. You should have a pen, some blank paper, and an empty USB stick (or other storage device) on which to save your programs. You must not use any other material such as files on a computer network, books or other written information. You may not communicate with anyone, other than the person invigilating this paper. Mark the first page of your written answers with your name, age in years and school/college. Number all pages in order if you use more than one sheet. All of your computer programs should display your name and school/college when they are run, and the storage device you use to submit the programs should also show your name and school/college. For your programs to be marked, the source code must be saved, along with executables if your language includes a compiler; this includes programs used to help answer written questions. You must clearly indicate the name given to each program on your answer sheet(s). Sample runs are given for parts 1(a), 2(a) and 3(a). Bold text indicates output from the program, and normal text shows data that has been entered. Where multiple items of input appear on the same line they should be separated by a single space. The output format of your programs should follow the sample run examples. Your programs should take less than 2 seconds of processing time for each test. Attempt as many questions as you can. Do not worry if you are unable to finish this paper in the time available. Marks allocated to each part of a question are shown in square brackets next to the questions. Partial solutions (such as programs that only get some of the test cases correct within the time limit, or partly completed written answers) may get partial marks. Questions can be answered in any order, and you may answer the written questions without attempting the programming parts. Hints If you can only see how to solve part of a problem it is worth writing a program that solves that part. We want to give you marks and questions are evaluated using multiple tests of differing difficulty. Remember, partial solutions may get partial marks. Question 2 is an implementation challenge and question 3 is a problem solving challenge. Most written questions can be solved by hand without solving the programming parts. Do not forget to indicate the name given to your programs on your answer sheet(s). Microsoft Studios Logo are trademarks of the Microsoft group of companies and are used under license from Microsoft.

Question 1: Watching the Clock Two clocks, which show the time in hours and minutes using the 24 hour clock, are running at different speeds. Each clock is an exact number of minutes per hour fast. Both clocks start showing the same time (00:00) and are checked regularly every hour (starting after one hour) according to an accurate timekeeper. What time will the two clocks show on the first occasion when they are checked and show the same time? NB: For this question we only care about the clocks matching when they are checked. For example, suppose the first clock runs 1 minute fast (per hour) and the second clock runs 31 minutes fast (per hour). When the clocks are first checked after one hour, the first clock will show 01:01 and the second clock will show 01:31; When the clocks are checked after two hours, they will show 02:02 and 03:02; After 48 hours the clocks will both show 00:48. 1(a) [ 25 marks ] Write a program which reads in a two integers, each between 0 and 50,000 inclusive, indicating the number of minutes fast (per hour) of the first and second clock respectively. Sample run 1 1 31 00:48 You should output the time shown on the clocks when they first match. Both the hour and the minutes should be displayed with two digits. 1(b) [ 3 marks ] Suppose the first clock is accurate and the clocks do not show 00:00 when they first match. The second clock is less than 20 minutes fast (per hour). How many minutes fast is the second clock? Write out all the possible answers. 1(c) [ 4 marks ] Suppose the two clocks can be any number of full minutes fast per hour. What is the largest number of hours that can pass before the clocks first match? Page 2 of 5

Question 2: Neutron The game of neutron 1 is played on a 5 5 board between two players. The players have five pieces each and there is an additional neutron piece on the board. Each space on the board is either empty or contains a single piece. The object of the game is to manoeuvre the neutron to a space on either the top or bottom row of the board. 1 8 2 For convenience we will denote directions on the board as follows: Players take alternate turns, each of which consists of first moving the neutron piece and then moving one of their own pieces. A piece is moved by sliding it as far as possible either horizontally, vertically or diagonally. If the neutron is moved to the bottom row the first player wins, if it reaches the top row the second player wins; it does not matter on whose turn the neutron was moved. If a player is unable to complete their turn (by being unable to move the neutron or subsequently one of their own pieces) the other player wins. 7 6 5 4 3 For example, consider the board on the right. The first player s pieces are denoted in white and the second player s pieces in black. The neutron is denoted by a star. Suppose it is the first player s turn. The neutron has to be moved first. It can move in direction 1 (in which case it reaches the top of the board and the game ends with the second player winning) or direction 6 (reaching the bottom and winning the game for the first player) and cannot move in directions 2 or 4 (being blocked by ❷ and ❺ respectively). In can also move in directions 3, 5, 7 and 8 in which case the first player then needs to move one of their pieces. ➃ ❹ ❸ ➂ ➀ ➁ If the first player decided to move the neutron in direction 8, followed by ➀ in direction 1, the board would look as it does on the left. If the second player then moved the neutron in direction 5, followed by the ❷ in direction 7, the board would look as it does in the right. Note that, in each case, pieces are moved as far as possible. ➃ ➀ ❹ ❸ ➂ ➁ ➃ ➀ ❹ ❸ ❶ ❺ ➂ ➁ For this question each player will use the following strategy: Each player has a fixed order in which they play their pieces (as the game progress). Once the last piece in their order has been played, they start again at the beginning of the order. E.g. if the player s order is 5, 4, 3, 2, 1 they will use (their) piece 5 on their first turn, 4 on their second,, 5 on their sixth turn, etc At the start of a turn, if they are able to move the neutron and immediately win the game for themselves the neutron is moved in the first such direction (from 1 to 8). If the only possible moves for the neutron will immediately win the game for their opponent, the neutron is moved in the first such direction (from 1 to 8). If the previous two conditions are not met, the player finds a way to play the next piece in their order. First the neutron is moved in the first direction (from 1 to 8) which does not end the game or prevent their chosen piece from moving, then the chosen piece is moved in the first direction (from 1 to 8) in which it can move. Your program will not be asked to deal with any cases where there is no valid turn for the neutron and player s chosen piece. At the start of the game the neutron is in the centre of the board. The first player s pieces occupy the bottom row and the second player s pieces occupy the top row. Pieces are in increasing order from left to right. ❶ ❷ ❸ ❹ ❺ ➀ ➁ ➂ ➃ ➄ 1 The actual game of neutron is slightly different to the description given here; you should only implement the rules detailed in the question. Page 3 of 5

2(a) [ 26 marks ] Write a program that plays neutron according to the given strategy. Your program should read in two lines of input. The first line of input will contain the digits 1, 2, 3, 4 and 5 in an order that represents the first player s fixed order. The second line of input will contain, in a similar format, the second player s fixed order. You should output the layout of the board at three moments during the game. The first layout should be after the first player s first turn; the second layout after the second player s first turn; the final layout after the game has terminated. All possible inputs to this question lead to a game that finishes. Your board should use an F for pieces belonging to the first player, an S for pieces belonging to the second player, a * for the neutron and a. for an unoccupied space. The three board layouts are marked independently and you can score marks if only one or two of your layouts are correct. Sample run 1 1 2 3 4 5 1 2 3 4 5 SSSSS F.*...FFFF.SSSS F...*...S..FFFF..SSS FF......SS.*FFF 2(b) [ 3 marks ] Suppose the layout of the board is as follows and that it is the start of the second (Black) player s turn. Ignoring the strategy, in how many ways can the player take their turn? ➃ ❹ ❸ ➂ ➀ ➁ 2(c) [ 4 marks ] Suppose the layout of the board is as follows at the beginning of a turn and that you do not know whose turn it is. Ignoring the strategy, how many different layouts could the board have been in at the start of the previous turn? ➃ ❷ ➀ ❶ ➄ ❹ ❸ ➁ ➂ ❺ Page 4 of 5

Question 3: Unlock A security system consists of a 5 5 keypad of buttons. Each button has a light which can be either off, dim or bright. When a button is pressed its light moves to the next state (off dim, dim bright and bright off) as do the lights on any buttons touching it horizontally and vertically. The system is unlocked when all the lights are off. A B C D E F G H I J K L M N O P Q R S T U V W X Y The current lighting can be represented by a string, in alphabetical order, where a lowercase letter indicates the corresponding button is dim and an uppercase letter indicates it is bright. Lights that are off do not have a letter in the string. For example, if all the buttons are off and button R is pressed, the lighting is mqrsw. If T is now pressed it becomes moqrstwy. Pressing S will make it mnoqrtwxy. 3(a) [ 24 marks ] Write a program to determine a sequence of button presses to unlock the system. Your program should read in a string of between 1 and 12 distinct letters (inclusive) in alphabetical order, representing the current lighting of the security system. You should output a string (in alphabetical order) that indicates a sequence of buttons which can be pressed to unlock the system, or output IMPOSSIBLE if it cannot be unlocked. A button can be pressed at most twice; a lowercase letter in your string will indicate that the corresponding button should be pressed once and an uppercase letter indicating that it should be pressed twice. Sample run mnoqrtwxy RST Alternative answer mnoqrtwxy acefhjprsuwy If there are multiple solutions you are only required to print out a single solution. 3(b) [ 2 marks ] What is the lighting of the system if the system is unlocked and then B is pressed, followed by I and O? (Each button being pressed once.) 3(c) [ 4 marks ] Starting from an unlocked system, in how many ways can three different buttons be pressed once each, in alphabetical order, so that no light becomes bright? 3(d) [ 5 marks ] Suppose that the system has a configuration of lighting and that a particular sequence of button presses will unlock the system. Is it possible for the same sequence of button presses to unlock the system when it is in a different configuration? Justify your answer. Total Marks: 100 End of BIO 2013 Round One paper Page 5 of 5