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

Similar documents
This chapter gives you everything you

ACM Collegiate Programming Contest 2016 (Hong Kong)

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

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}

The 2016 ACM-ICPC Asia China-Final Contest Problems

ProCo 2017 Advanced Division Round 1

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

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

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

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

2015 ACM ICPC Southeast USA Regional Programming Contest. Division 1

Cryptic Crosswords for Bright Sparks

Investigation of Algorithmic Solutions of Sudoku Puzzles

Beacons Proximity UUID, Major, Minor, Transmission Power, and Interval values made easy

Math 365 Wednesday 2/20/19 Section 6.1: Basic counting

Math 1111 Math Exam Study Guide

Today s Topics. Sometimes when counting a set, we count the same item more than once

Problem 2A Consider 101 natural numbers not exceeding 200. Prove that at least one of them is divisible by another one.

BMT 2018 Combinatorics Test Solutions March 18, 2018

CMSC 201 Fall 2018 Project 3 Sudoku

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

Programming Problems 14 th Annual Computer Science Programming Contest

Problem A. Jumbled Compass

Problem A. Alignment of Code

Buzz Contest Rules and Keywords

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

Rubik's Missing Link

CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

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

This screenplay may not be used or reproduced without the express written permission of the author. ( C )

Discrete Mathematics: Logic. Discrete Mathematics: Lecture 15: Counting

Problem D Daydreaming Stockbroker

The 2017 British Informatics Olympiad

Welcome to the Word Puzzles Help File.

Problem A: Watch the Skies!

2016 Canadian Computing Olympiad Day 2, Problem 1 O Canada

Problem Set 7: Network Flows Fall 2018

Problem F. Chessboard Coloring

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

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

Data Structure Analysis

WPF PUZZLE GP 2017 ROUND 5A COMPETITION BOOKLET. Host Country: Czech Republic C D. Author: Jan Novotný

COCI 2008/2009 Contest #2, 15 th November 2008 TASK KORNISLAV RESETO PERKET SVADA SETNJA CAVLI

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

Combinatorial Games. Jeffrey Kwan. October 2, 2017

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

CPCS 222 Discrete Structures I Counting

Amnesia - A Machine For Pigs Game Guide. 3rd edition Text by Cris Converse. eisbn

MATH 351 Fall 2009 Homework 1 Due: Wednesday, September 30

Problem A. Bubbly Troubly

Standard Puzzle Format

It Stands to Reason: Developing Inductive and Deductive Habits of Mind

TASK NOP CIJEVI ROBOTI RELJEF. standard output

Kenken For Teachers. Tom Davis January 8, Abstract

2005 Galois Contest Wednesday, April 20, 2005

Data Representation. "There are 10 kinds of people in the world, those who understand binary numbers, and those who don't."

Tutorial: Creating maze games

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

Numbers 01. Bob Albrecht & George Firedrake Copyright (c) 2007 by Bob Albrecht

The Joy of SVGs CUT ABOVE. pre training series 3. svg design Course. Jennifer Maker. CUT ABOVE SVG Design Course by Jennifer Maker

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

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

The original image. Let s get started! The final rainbow effect. The photo sits on the Background layer in the Layers panel.

Heuristics, and what to do if you don t know what to do. Carl Hultquist

Tiling Problems. This document supersedes the earlier notes posted about the tiling problem. 1 An Undecidable Problem about Tilings of the Plane

The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n ways to do the first task and n

Permutations. Example 1. Lecture Notes #2 June 28, Will Monroe CS 109 Combinatorics

CSE 21: Midterm 1 Solution

Grade 7/8 Math Circles. Visual Group Theory

SUDOKU1 Challenge 2013 TWINS MADNESS

Lecture 2: Sum rule, partition method, difference method, bijection method, product rules

Problem A. Ancient Keyboard

Topics to be covered

Philadelphia Classic 2013 Hosted by the Dining Philosophers University of Pennsylvania

Counting. Chapter 6. With Question/Answer Animations

ADD A REALISTIC WATER REFLECTION

1 Permutations. Example 1. Lecture #2 Sept 26, Chris Piech CS 109 Combinatorics

KenKen Strategies 17+

2. To receive credit on any problem, you must show work that explains how you obtained your answer or you must explain how you obtained your answer.

Sponsored by IBM. 6. The input to all problems will consist of multiple test cases unless otherwise noted.

UW-Madison ACM ICPC Individual Contest

Ask a Scientist Pi Day Puzzle Party askascientistsf.com. Ask a Scientist Pi Day Puzzle Party askascientistsf.com

Notes on 4-coloring the 17 by 17 grid

With Question/Answer Animations. Chapter 6

Keeping secrets secret

2008 학년도대학수학능력시험 9 월모의평가듣기대본

Math Circle: Logic Puzzles

Games of Skill Lesson 1 of 9, work in pairs

Problem A: Complex intersecting line segments

Comparing Methods for Solving Kuromasu Puzzles

Jamie Mulholland, Simon Fraser University

Game Maker Tutorial Creating Maze Games Written by Mark Overmars

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

Problem ID: coolestskiroute

SOME EXAMPLES FROM INFORMATION THEORY (AFTER C. SHANNON).

Name 17-4A. 1. Which is the least horizontal distance between two of the points shown at the right? A 1 unit B 2 units C 4 units D 6 units

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

I.M.O. Winter Training Camp 2008: Invariants and Monovariants

1 Permutations. 1.1 Example 1. Lisa Yan CS 109 Combinatorics. Lecture Notes #2 June 27, 2018

WPF PUZZLE GP 2016 ROUND 6 COMPETITION BOOKLET. Host Country: Serbia. Nikola Živanović, Čedomir Milanović, Branko Ćeranić COMPETITIVE

Transcription:

Problem AC. Art Museum file: 6 seconds 6 megabytes EPFL (Extreme Programmers For Life) want to build their 7th art museum. This museum would be better, bigger and simply more amazing than the last 6 museums. This would make EPFL great again. To achieve this, EPFL will not only require the help of top-notch Japanese architects, but also of all Martians. However, the Martians are spread across several galaxies and therefore have different time availabilities. You thought the time difference between Europe and USA was annoying? Help EPFL find the maximum number of galaxies that are available at the same hour? The first line contains the integer n, the number of galaxies (1 n 10 ). On each of the next n lines, there will be two space-separated integers, a and b (0 a<b ). This means that the Martians of this galaxy are available from the beginning of the a-th hour to the beginning of the b-th hour. Print the maximum number of galaxies available in any timeslot of one hour. Examples 1 1 1 1 7 9 16 16 18 1 1 9 0 0 Note 1 In the first example, the Martians of the first galaxy are available from 01:00 to 1:00, and the Martians of the second galaxy are available from 1:00 to 1:00. Therefore, at any given hour, the maximum number of available galaxies is 1. In the second example, the timeslots in which galaxies are available are: 9:00-1:00, 1:00-16:00, and 16:00-18:00. No one-hour timeslot has more than galaxies available. Therefore, the answer is.

Problem BE. Secret Passage file: 6 seconds 1 megabytes The Martians have invaded EPFL. Five minutes ago, they were at Esplanade and started heading towards the EPFL metro station to destroy it so that no student can return home (no one likes taking the bus anyway, and walking is just too hard!). You are currently at Esplanade, and you need to get to the metro station before they do. Luckily, you know some secret passageways and can perhaps take a shortcut. You are given the map to EPFL as an n x m grid, with some obstacles. Esplanade is at the top left corner with index (0, 0), and the metro station is at the bottom right corner with index (n - 1, m - 1). The Martians (and you) can move vertically or horizontally on the grid, and need 1 minute to go from one cell to another. The cells that are obstacles cannot be traversed. You are also given k coordinates. These are the obstacles that you can walk (or run!) through but the Martians can t because they don t know about. Can you get to the metro station before them? The first line will contain three space-separated integers n, m and k (1 n, m 00; 1 k 10 ). Each of the next n lines will have a string s i of length m, representing row i in the EPFL map. Each character in s i will be either a. representing a clear passage or a x representing an obstacle. Each of the next k lines will contain two space-separated integers r and c, where (r, c) represents an obstacle in the original graph that you can use as a secret passage (0 r n 1; 0 c m 1). All k (r, c) are obstacles in the original graph, and are pair-wise distinct. The top left and bottom right corners of the EPFL map will not be obstacles. Print on a single line the word YES if you can reach the metro station strictly before the Martians do. Otherwise, print NO. Examples 1... xxxx.....xxxx... 1..x.....x. x.x....x.x.x.x. YES NO

Note In the first example, the Martians need 16 minutes to reach the metro station. You, on the other hand, know the secret passage through (, ), which allows you to reach the metro station in 8 minutes. Even though you started minutes after the Martians, you still arrive before them! In the second example, neither you nor the Martians can reach the metro station. If only obstacle (0, ) was also a secret passage, you would have been able to reach.

Problem CA. Salient Strings file: 0 seconds 10 megabytes Many people are avid fans of the daily crossword in the paper, but not you. I mean, the format is pretty terrible, right? You only get to use English words, and any hack can look those up in a dictionary. Also, it takes forever to make just one puzzle. What a waste of time. You ve written a letter to the editor describing a new word game. It s really easy to make new puzzles because the only thing you give the solver is a permutation P 1..N of the first N positive integers. It s then up to the solver to find any string that s salient for the given permutation. A string is salient for the permutation P 1..N if it consists of N uppercase letters ( A... Z ), such that when its N non-empty suffixes are sorted in lexicographical order, the suffix starting at the i-th character is the P i -th suffix in the sorted list. It s possible that a given permutation has no salient strings. You need some example puzzles to include in your letter. You already have some permutations generated, so all you need is to supply an answer for each permutation (if possible). begins with an integer T (1 T 000), the number of different permutations you ve generated. For each permutation, there is first a line containing the integer N(1 N 1000). Then N lines follow, the i-th of which contains the integer P i (1 P i N). It is guaranteed that each integer from 1 to N shows up exactly once in P. For the i-th permutation, print a line containing Case #i: followed by any salient string for that permutation (note that any valid string consisting of N uppercase letters will be accepted), or -1 if there are no such strings.

Example 8 1 8 7 6 1 9 6 9 8 7 1 Note Case #1: FACEBOOK Case #: FOXEN Case #: HUEHUEHUE In the first case, if we sort the suffixes of FACEBOOK we get: 1. ACEBOOK. BOOK. CEBOOK. EBOOK. FACEBOOK 6. K 7. OK 8. OOK If we read the indices of the suffixes back in order of decreasing length, we get 1 8 7 6, which is the given permutation. Therefore FACEBOOK is salient for this permutation, and is one possible accepted answer.

Problem D. Rain Over New York file: 0 seconds 10 megabytes You re looking at a sort of clock which has a row of N lights. Each light is either on or off, and their states can be read as an N-digit binary number. The first light represents the most significant (leftmost) digit while the N-th light represents the least significant digit. A light that s on corresponds to a 1, and alightthat soff corresponds to a 0. You ve just started looking at the clock, and you know that every second from now on, it will count upwards by 1, with its lights turning on or off to display the next number in binary. Once the clock displays N 1 (with all N lights on), it will wrap around to display 0 (with all lights off) on the following second, and then continue counting up again. However, 0 or more of the clock s lights may be permanently broken. You don t know which ones those are, but you know that they ll always appear to be off, even when they should be on. Currently, the i-th light appears to be on if L i =1, and otherwise appears to be off (if L i =0). You have also received insider information that exactly K of the lights are currently supposed to be on. It s guaranteed that K is at least as large as the number of lights which appear to be on. Assuming you stand around and look at this clock for a while, what s the maximum amount of time you might have to wait before you can be completely sure of what state every single light is currently supposed to be in? It s possible that you can be sure immediately, after 0 seconds. On the other hand, it s also possible that you might never be sure, no matter how long you wait. begins with an integer T (1 T 000), the number of different clocks you own. For each clock, there is first a line containing the two space-separated integers, N(1 N 60) and K(0 K N). Then there is a line containing N space-separated integers, the i-th of which is L i (0 L i 1). For the i-th clock, print a line containing Case #i: followed by the maximum number of seconds which might go by before you know the true current state of each light, or -1 if you might never know.

Example 1 0 0 0 0 1 7 0 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 0 1 1 0 0 0 1 1 1 1 0 0 1 0 19 0 1 1 0 1 0 0 0 1 1 0 0 0 1 1 0 1 0 1 0 Case #1: Case #: -1 Case #: 19 Case #: 17601 Case #: 819 Note In the first case, exactly one of the two rightmost lights is initially supposed to be on, so the clock is either supposed to be showing 101 () or 110 (6). After one second, the clock will be supposed to show either 110 (6) or 111 (7). Supposing that the two rightmost lights are both broken, both of these values will still look like 100 to you, so you won t be able to tell which one is correct. After one more second, the clock will be supposed to show either 111 (7) or 000 (0). At that point, by observing the functioning leftmost light, you can determine whether all three lights are supposed to be on or off at that moment. In the second case, you ll never be able to tell which of the two leftmost lights are supposed to be on if they re both broken.

Problem EG. Pick Your Team file: seconds 6 megabytes This is it. The final battle between EPFL and Mars. The rules of the game are as follows. Neither side wants to sacrifice their own people, so we will be picking two teams of Unil students to fight each other instead. You have been chosen to pick the team that will fight for EPFL s honour! You are given a list containing the strength of each Unil student. You start by choosing one student to join your team, then the Martians will choose another student, and so on, until all n students are chosen. If you had no extra information, clearly you d pick the strongest Unil student in each turn. However, we managed to figure out the preference of the Martians. More specifically, we have a permutation P of the first n numbers, representing the indices of the Unil students, which the Martians prefer to pick in order. Take a look at the example inputs to understand this further. You want to pick the team that maximises the difference between your team s strength and theirs. What s the maximum difference? The first line of the input has of an even integer n ( n 100), the number of Unil students. The next line contains n space-separated integers s i, the strength of each student (1 s i 10 7 ). The last line contains n space-separated integers between 1 and n, representing the permutation P. Print the maximum difference in strength between your team and the Martians team. Examples 9 1 7 1 10 1 1 6 6 8 10 9 8 7 6 10 1 Note 1 1 In the first example, there are four Unil students with strengths, 9, 1, 7. The Martians prefer to pick them in this order:, 1,,. This means that in their first turn, they ll pick student (strength = 7) if that student hadn t been picked, otherwise they ll pick the next student on their list (student 1, strength = ). If you had used the simple strategy of picking the strongest available student each turn, you d have ended up with a total strength of 9 + = 1, and the Martians with 7 + 1 = 8, giving you a difference of. Given this extra information, you can first pick student (strength = 7), then student (strength = 9) in your next turn. You d have a difference of 9 + 7 - - 1 = 1. In this case, this is the best strategy.

Problem FC. Central Element file: This is an interactive problem. There is a permutation P of numbers 1 through n, not known to you, P = hp 1,P,...,P n i. You can ask the following type of questions: Given three distinct positions i, j and k, which of P i, P j and P k is central? Element is central if it is neither minimal nor maximal. For example, if the permutation is h, 1,, i, and you ask about positions 1,, and, you receive, because is the central element of the set {P 1,P,P } = {, 1, }. Note that you don t get the information at which position among 1,, and it is located. Your task is to find the permutation P. Actually, for each permutation P there is a set S(P ) of permutations that cannot be distinguished from P using the allowed questions. You must find any permutation from this set. Interaction protocol First, your program must read from the one line with the integer n, the size of the permutation. The program must write to the one line with three positions that you ask a question about and wait for a line in the with a response, then write next question and read next response, and so on until you know the permutation P up to S(P ). Once you know the answer, output one line with the word OK and the permutation P. The first line of the contains n, the size of the permutation ( n 00). Each of the next lines of the contains response to your question the number that is central among the numbers at the asked positions. When you re asking questions, each line of the should contain three diæerent integers from the range of 1 to n, space-separated. You can ask at most 000 questions. When you re stating the answer, the line of the should contain the word OK, and the numbers P 1,P,...,P n, all space-separated. After printing this line your program must exit. You must flush after printing each line. Sample input and output 1 1 1 OK 1