SAPO Finals 2017 Day 2 Cape Town, South Africa, 8 October standard output

Similar documents
ProCo 2017 Advanced Division Round 1

Q i e v e 1 N,Q 5000

Problem A. First Mission

Codebreaker Lesson Plan

SMT 2014 Advanced Topics Test Solutions February 15, 2014

TASK OKUPLJANJE USPON RAZINE ABECEDA STEP VODA. uspon.pas uspon.c uspon.cpp. razine.pas razine.c razine.cpp

UKMT UKMT UKMT. Junior Kangaroo Mathematical Challenge. Tuesday 12th June 2018

Memory. Introduction. Scratch. In this project, you will create a memory game where you have to memorise and repeat a sequence of random colours!

CPSC 217 Assignment 3

TASK PATRIK POLICIJA SABOR

Problem A. Subway Tickets

CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

In this project, you will create a memory game where you have to memorise and repeat a sequence of random colours!

Problem A. Vera and Outfits

Gough, John , Logic games, Australian primary mathematics classroom, vol. 7, no. 2, pp

ACM Collegiate Programming Contest 2016 (Hong Kong)

George Fox University H.S. Programming Contest Division - I 2018

2016 Canadian Computing Olympiad Day 2, Problem 1 O Canada

TASK NOP CIJEVI ROBOTI RELJEF. standard output

1 Stove. Task. Input. Output. Constraints

INTERMEDIATE. Grades 8 and 9 NOT TO BE USED BEFORE 5 MARCH If you are NOT in grades 8 or 9, please report that you have the wrong paper.

Patterns and rules repeating patterns

Static Mastermind. Wayne Goddard Department of Computer Science University of Natal, Durban. Abstract

The 2016 ACM-ICPC Asia China-Final Contest Problems

UMBC 671 Midterm Exam 19 October 2009

TASK BELA PUTOVANJE PIANINO PAROVI KRUMPIRKO SAN. standard input (stdin) standard output (stdout)

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

Irish Collegiate Programming Contest Problem Set

Pay attention to how flipping of pieces is determined with each move.

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

CS188: Section Handout 1, Uninformed Search SOLUTIONS

2016 CCSC Eastern Conference Programming Competition

Power Solutions November 19, 2017

Mittwoch, 14. September The Pelita contest (a brief introduction)

Spring 06 Assignment 2: Constraint Satisfaction Problems

2009 ACM ICPC Southeast USA Regional Programming Contest. 7 November, 2009 PROBLEMS

Croatian Open Competition in Informatics, contest 6 April 12, 2008

class TicTacToe: def init (self): # board is a list of 10 strings representing the board(ignore index 0) self.board = [" "]*10 self.

Similarly, for N players in a round robin tournament, where every player plays every other player exactly once, we need to arrange N (N 1) games.

Fall 2018 #8 DFS-Strong-Comps. A. Cut 'em all! 1 second, 256 megabytes

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

2017 Denison Spring Programming Contest Granville, Ohio 18 February, 2017

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

TASK KAMPANJA MJESEC SETNJA TRAMPOLIN. mjesec.pas mjesec.c mjesec.cpp. standard input (stdin) standard output (stdout)

CS 540-2: Introduction to Artificial Intelligence Homework Assignment #2. Assigned: Monday, February 6 Due: Saturday, February 18

Southeastern European Regional Programming Contest Bucharest, Romania Vinnytsya, Ukraine October 21, Problem A Concerts

Problem A. Jumbled Compass

Olympiad Combinatorics. Pranav A. Sriram

Counting. Chapter 6. With Question/Answer Animations

SMS Dictionary. Solution hint. Input format. Output format. (Indian National Olympiad in Informatics, INOI, 2007)

Advanced Excel. Table of Contents. Lesson 3 Solver

ACM International Collegiate Programming Contest 2010

2006 Canadian Computing Competition: Junior Division. Sponsor:

Outline. Content The basics of counting The pigeonhole principle Reading Chapter 5 IRIS H.-R. JIANG

South African Computer Olympiad Web Training, 2009 IOI Squad March Contest. Overview. Michiel Baird. Problem bnumbers hotdates connect wifitow

The 2017 British Informatics Olympiad

SUDOKU X. Samples Document. by Andrew Stuart. Moderate

South African Computer Olympiad Final Round Day 2. Overview. Carruthers- Smith Problem parrots seen search. seen.java seen.py seen.c seen.cpp seen.

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

Carnegie Mellon University. Invitational Programming Competition. Eight Problems

CS 32 Puzzles, Games & Algorithms Fall 2013

Spring 06 Assignment 2: Constraint Satisfaction Problems

Input. Output. Examples. Note. Input file: Output file: standard input standard output

Problem Set 10 2 E = 3 F

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

Problem A. Worst Locations

The 2009 British Informatics Olympiad

The Product Rule can be viewed as counting the number of elements in the Cartesian product of the finite sets

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

Kenken For Teachers. Tom Davis January 8, Abstract

UCF Local Contest August 31, 2013

The 2013 British Informatics Olympiad

YourTurnMyTurn.com: Rules Minesweeper. Michael A. Coan Copyright Coan.net

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

FRI Summer School Final Contest. A. Flipping Game

1. Completing Sequences

In this project you will learn how to write a Python program telling people all about you. Type the following into the window that appears:

2015 ACM ICPC Southeast USA Regional Programming Contest. Division 1

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

Problem ID: coolestskiroute

Mathematical Olympiad for Girls

CS 787: Advanced Algorithms Homework 1

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

Caltech Harvey Mudd Mathematics Competition February 20, 2010

Final Project (Choose 1 of the following) Max Score: A

Printing: You may print to the printer at any time during the test.

Intermediate Mathematics League of Eastern Massachusetts

Unimelb Code Masters 2015 Solutions Lecture

Mastermind Revisited

Senior Math Circles February 10, 2010 Game Theory II

Concept Connect. ECE1778: Final Report. Apper: Hyunmin Cheong. Programmers: GuanLong Li Sina Rasouli. Due Date: April 12 th 2013

Combinatorial Games. Jeffrey Kwan. October 2, 2017

ISudoku. Jonathon Makepeace Matthew Harris Jamie Sparrow Julian Hillebrand

ENEE 150: Intermediate Programming Concepts for Engineers Spring 2018 Handout #7. Project #1: Checkers, Due: Feb. 19th, 11:59p.m.

SMT 2013 Advanced Topics Test Solutions February 2, 2013

Math Contest Preparation II

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

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

Team Round University of South Carolina Math Contest, 2018

NIM Games: Handout 1

Transcription:

Problem A. Cave Input file: Output file: 3 seconds 6 seconds 30 seconds 128 megabytes cave For reasons unknown, Bruce finds himself waking up in a large cave. Fortunately, he seems to have a map of the layout of the cave, as well as K sticks of dynamite to blast his way to the exit. As Bruce is afraid of the dark, he wishes to escape as quickly as possible, and has thus asked you to write a program which will determine his shortest escape route. The cave is modeled as an N by M grid of cells. Each cell is either solid or empty. A valid escape route consists of Bruce taking a number of steps from his starting location to finish at the exit. In each step, Bruce can move from his current cell to an adjacent empty cell. If he has at least one stick of dynamite left, he may instead use a stick of dynamite to move to an adjacent solid cell. The length of the escape route is the number of steps it consists of. Input The first line contains three space-separated integers N (1 N 500), M (1 M 500), and K (1 K 50). The following N lines each contain M characters, depicting the cave.. denotes an empty cell. # denotes a solid cell. S denotes the empty cell where Bruce starts, and occurs exactly once in the input. E denotes the empty cell where Bruce can exit the cave, and occurs exactly once in the input. Output A single integer, which is the length of the shortest valid escape route. If there is no such escape route, output -1 instead. Scoring Subtask 1 (10 points): N = 1 Subtask 2 (10 points): There is no cell of type #. Subtask 3 (25 points): K = 0 Subtask 4 (20 points): K = 1 Subtask 5 (35 points): No further restrictions 6 8 2.S... ########.###....#.#####.#...###...#..#E 15 Page 1 of 5

Problem B. Tigers Input file: Output file: 2 seconds 4 seconds 20 seconds 64 megabytes tigers Alexandra was walking through the Siberian forest one day when she suddenly noticed she was being watched. Up atop a cliff face in front of her was Boris the Siberian Tiger, lingering ominously. Alexandra is best friends with Boris, but she knows that Boris might decide to eat her if he feels hungry. Alexandra would therefore like to work out how many ways Boris can jump down the cliff face to the ground to eat her so she can plan her escape if necessary. The cliff consists of N ledges. Ledge i is h i units above the ground and is x i units to the right of Alexandra (and can be considered a single point on the cliff face). Boris starts at the highest ledge, and repeatedly jumps down to a ledge strictly lower (or directly to the ground) until he reaches the ground. Specifically, if Boris is on ledge i, he may jump directly to the ground, or to any ledge j which has height h j < h i and x j x i L, where L is Boris s jumping range. Alexandra would like to know the number of ways Boris can jump between ledges to reach the ground. Since the answer to Alexandra s question may be large, you should output the the remainder of the answer when divided by 10 9 + 7. Help Alexandra avoid being eaten by Boris. Input The first line consists of two space-separated integers, N (1 N 100 000) and L (0 L 100 000). The next N lines contain two integers each. On the ith of these lines is x i (0 x i 100 000) and h i (1 h i 1 000 000), describing the position of the ith ledge (where 1 i N). It is guaranteed that the heights of the ledges will be distinct. Output Output a single integer denoting the number of ways Boris can jump between ledges to reach the ground, modulo 10 9 + 7. Scoring Subtask 1 (10 Points): N 6 Subtask 2 (15 Points): N 100 000, L = 100 000 Subtask 3 (35 Points): N 1 000 Subtask 4 (40 Points): N 100 000 3 2 5 10 7 8 8 5 3 Page 2 of 5

Note In the sample input, there are ledges at points (5, 10), (7, 8) and (8, 5) respectively. Boris starts at the highest ledge (5, 10). Here are all the possible ways Boris can reach the ground: 1. (5, 10) ground 2. (5, 10) (7, 8) ground 3. (5, 10) (7, 8) (8, 5) ground Page 3 of 5

Problem C. Mastermind 5 seconds 10 seconds 50 seconds 1024 megabytes mastermind Mastermind is a popular two-player game first invented in the 1970s. One player is the codemaker and the other player is the codebreaker. The ultimate goal of the game is for the codebreaker to guess a secret pattern that the codemaker chooses at the start. The game starts by having the codemaker think of a secret pattern of length N, using positive integers ranging from 1 to K. Duplicate numbers are allowed. The codebreaker then attempts to guess the pattern the codemaker has thought of. The codebreaker presents his guess to the codemaker, after which the codemaker provides feedback by giving 2 numbers A, B. The first number A denotes the number of correct colours in the correct positions, and the second number B denotes the number of correct colours in the wrong positions. After the codebreaker received his feedback, he should make another guess, after which more feedback will be given. This continues back and forth until the codebreaker correctly guesses the pattern the codemaker thought of. Note: If there are duplicate numbers in the guess, they cannot all be counted unless they correspond to the same number of duplicate numbers in the secret pattern. For example, if the secret pattern is 4 1 1 1 and the codebreaker guesses 2 4 4 3, then the judge will return 0 1. Similarly, if the guess 4 4 3 3 is made, the judge will return 1 0. Formally speaking, if P i denotes the number of times i appears in the secret pattern and G i denotes the number of times i appears in the guess, then B can be calculated as: ( K ) B = min(p i, G i ) A = (min(p 1, G 1 ) + min(p 2, G 2 ) + + min(p K, G K )) A i=1 Note: There is no intrinsic limit to the number of guesses you are allowed. Rather your score for a particular task will be calculated based on the number of guesses you needed before correctly guessing the codemaker s pattern. Interaction Protocol This is an interactive task. You are thus required to compile your code against a stub that will perform the interaction with the grader for you. You are required to write two functions, init and makeguess. The functions must have the following signatures: Python def init(n,k) def makeguess(a, B) C++ vector<int> init(int N, int K); vector<int> makeguess(int A, int B) Java public static int[] init(int N, int M) public static int[] makeguess(int A, int B) When your program is run, the function init will be called once with the parameters N, K. The function init should then output a list/array of integers containing an initial guess of the secret pattern. Subsequently, the stub will call then makemove with the values of A and B until you correctly guess the secret pattern. For every function call makemove, you must return another guess for the pattern. Page 4 of 5

Scoring Subtask 1 (at most 10 points): N 3, K 2 Subtask 2 (at most 16 points): N 2 Subtask 3 (at most 16 points): K 2 Subtask 4 (at most 18 points): N, K 5 Subtask 5 (at most 20 points): N, K 8 Subtask 6 (at most 20 points): No further constraints Each test case can give a maximum of 2 points. If your program correctly guesses the secret pattern in G guesses, then your score S for that particular test case is: ( ) 4(N + K) S = min, 2 points 3G Function Call Function Response init(4,6) {2, 5, 3, 6} makeguess(1,1) {2, 4, 5, 6} makeguess(1,1) {4, 6, 3, 1} makeguess(2,0) {4, 2, 3, 6} makeguess(2,1) {4, 4, 3, 2} In the given example, the codemaker creates the secret pattern: 4 4 3 2. The codebreaker then begins by guessing the sequence 2 5 3 6. He has one number, 3, in the correct position and another number, 2, which is correct, but in the wrong position, hence the judge gives a result of 1 1. He guesses again, this time getting 4 in the correct position and still 2 in the wrong position, hence the judge returns 1 1 again. His third guess gets two numbers in the correct position: the numbers 4 and 3. No other number is correct, so the judge returns 2 0 His fourth guess gets both 4 and 3 in the correct position and 2 in the wrong position, so the judge returns 2 1 His final guess matches the codemaker s secret pattern exactly. The judge therefore exits and the pattern was correctly guessed in G = 5 guesses. Note Testing your program is made easier with the supplied stub code and manager. To compile and test your program, run the script run.sh with the name of an input file and the name of your source code. The script will automatically compile your code against the stub, and run it against the grader. It will output your code s responses to the input. The format of the input file is as follows. The first line must contain two space separated integers, N and K. The next line contains N space-separated integers denoting the secret pattern to guess. For example, to test a solution written in java against the sample input, you must run./run.sh mastermind.java sample.in If your stubs, graders or compilation scripts are corrupted during the contest, you may re-download them from the problem statement on the web interface. Page 5 of 5