Problem A: Complex intersecting line segments

Similar documents
Problem F. Chessboard Coloring

Second Annual University of Oregon Programming Contest, 1998

Math 3560 HW Set 6. Kara. October 17, 2013

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

BMT 2018 Combinatorics Test Solutions March 18, 2018

Figure 1: The Game of Fifteen

GAMES AND STRATEGY BEGINNERS 12/03/2017

MATH 255 Applied Honors Calculus III Winter Homework 1. Table 1: 11.1:8 t x y

The Canadian Open Mathematics Challenge November 3/4, 2016

Senior Math Circles February 10, 2010 Game Theory II

On Variations of Nim and Chomp

2005 Fryer Contest. Solutions

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

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

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

Jim and Nim. Japheth Wood New York Math Circle. August 6, 2011

PRIMES STEP Plays Games

2015 ACM ICPC Southeast USA Regional Programming Contest. Division 1

Problem Set 7: Games Spring 2018

ProCo 2017 Advanced Division Round 1

Math is Cool Masters

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

13.2 Define General Angles and Use Radian Measure. standard position:

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

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

Plan. Related courses. A Take-Away Game. Mathematical Games , (21-801) - Mathematical Games Look for it in Spring 11

Mathematics. Programming

Areas of Various Regions Related to HW4 #13(a)

Programming Problems 14 th Annual Computer Science Programming Contest

The 2016 ACM-ICPC Asia China-Final Contest Problems

THE NUMBER WAR GAMES

Grade 6 Math Circles Combinatorial Games - Solutions November 3/4, 2015

Students use absolute value to determine distance between integers on the coordinate plane in order to find side lengths of polygons.

Problem A: Watch the Skies!

Grade 6 Math Circles Combinatorial Games November 3/4, 2015

Hackenbush. Nim with Lines (and something else) Rules: Example Boards:

Grade 7/8 Math Circles Game Theory October 27/28, 2015

(D) 7 4. (H) None of these

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

UW-Madison ACM ICPC Individual Contest

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

NIM Games: Handout 1

2015 Canadian Computing Olympiad Day 2, Problem 1 Cars on Ice

High School Math Contest. Prepared by the Mathematics Department of. Rose-Hulman Institute of Technology Terre Haute, Indiana.

Duke Math Meet Individual Round

A1 Problem Statement Unit Pricing

Cayley Contest (Grade 10) Thursday, February 25, 2010

On Variants of Nim and Chomp

Daniel Plotnick. November 5 th, 2017 Mock (Practice) AMC 8 Welcome!

13.4 Chapter 13: Trigonometric Ratios and Functions. Section 13.4

Probability 1. Name: Total Marks: 1. An unbiased spinner is shown below.

PLAYERS AGES MINS.

Irish Collegiate Programming Contest Problem Set

Problem A. Backward numbers. backw.in backw.out

Game Theory and Algorithms Lecture 19: Nim & Impartial Combinatorial Games

UCF Local Contest August 31, 2013

Norman Do. Department of Mathematics and Statistics, The University of Melbourne, VIC

SUMMER MATHS QUIZ SOLUTIONS PART 2

Tangent: Boromean Rings. The Beer Can Game. Plan. A Take-Away Game. Mathematical Games I. Introduction to Impartial Combinatorial Games

MATH 105: Midterm #1 Practice Problems

CSE101: Algorithm Design and Analysis. Ragesh Jaiswal, CSE, UCSD

Pythagorean Theorem: Trigonometry Packet #1 S O H C A H T O A. Examples Evaluate the six trig functions of the angle θ. 1.) 2.)

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

Problem Score Jill's Genome Latin Squares

Math 122: Final Exam Review Sheet

2013 Mid-Atlantic Regional Programming Contest

2008 Canadian Computing Competition: Senior Division. Sponsor:

Selected Game Examples

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

Grade 7/8 Math Circles. February 14 th /15 th. Game Theory. If they both confess, they will both serve 5 hours of detention.

Problem A. Subway Tickets


1. Completing Sequences

Ian Stewart. 8 Whitefield Close Westwood Heath Coventry CV4 8GY UK

ANGLO-CHINESE JUNIOR COLLEGE MATHEMATICS DEPARTMENT. Paper 2 26 August 2015 JC 2 PRELIMINARY EXAMINATION Time allowed: 3 hours

Pascal Contest (Grade 9)

Week 1. 1 What Is Combinatorics?

Prerequisite Knowledge: Definitions of the trigonometric ratios for acute angles

Algebra 2/Trig AIIT.13 AIIT.15 AIIT.16 Reference Angles/Unit Circle Notes. Name: Date: Block:

Impartial Combinatorial Games Berkeley Math Circle Intermediate II Ted Alper Evans Hall, room 740 Sept 1, 2015

Analyzing Games: Solutions

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

Probability. Misha Lavrov. ARML Practice 5/5/2013

Combinatorial Games. Jeffrey Kwan. October 2, 2017

SAMPLE !!CAUTION!! THIS IS ONLY A SAMPLE PAPER !!CAUTION!! THIS PAPER IS MEANT ONLY FOR PRACTICE

Midterm (Sample Version 3, with Solutions)

Where should Sam and Marla Wilson look for a new apartment that is equidistant from their jobs?

Foundations of Computing Discrete Mathematics Solutions to exercises for week 12

Team Round University of South Carolina Math Contest, 2018

SYDE 112, LECTURE 34 & 35: Optimization on Restricted Domains and Lagrange Multipliers

BAPC The Problem Set

10.1 Curves defined by parametric equations

Multiplying and Dividing Integers

Trigonometric Identities

of the whole circumference.

Problem A. First Mission

Binary Games. Keep this tetrahedron handy, we will use it when we play the game of Nim.

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

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

Games, Triangulations, Theory

Transcription:

Problem A: Complex intersecting line segments In this problem, you are asked to determine if a set of line segments intersect. The first line of input is a number c 100, the number of test cases. Each test case is a single line containing four complex numbers s 1, t 1, s, t separated by spaces. Each complex number a+bi represents a point (a, b) in the xy-plane. In all cases, a and b will be integers between 100 and 100 for a complex number a + bi. Note that the real part of the complex number may be omitted if it is 0 and the imaginary part may be omitted if it is 0 (and if both are 0, the number is written 0). Also, if the imaginary part is +1 or 1, that part may be written as +i or i (rather than +1i and 1i). See sample input for examples. All line segments given as input have non-zero length (i.e., the two endpoints are always different). For each test case, you should output a single line containing intersect if the line segment from s 1 to t 1 intersects the line segment from s to t (the endpoints are considered to be part of the segment) and do not intersect otherwise. Sample input 3 -i --i +i -+i 1+i -i +i 1-i 0 i 1-1+i Sample output do not intersect intersect intersect 1

Problem B: Transformation In a world where 1 + 1 + 1 = sits a grid of integer between 0 and 15 (inclusively). In this grid, a maximal connected component of size at least 3 containing only the number i > 0 transforms into a single number i + 1 mod16. This new number is located in the bottom most row of the originating component and at the leftmost position in that row. 1 1 1 0 0 1 0 3 0 0 0 0 3 0 3 0 0 3 0 3 0 0 3 0 0 0 0 0 0 4 0 0 Numbers transform in rounds. That is, all numbers on the grid transform if they are able to. Then all numbers in the new grid transform if they are able to, and so on. This continues until no transformation is possible The number 0 never transforms. The first line of input is a number c 0, the number of test cases. The first line of each test case contains two numbers m 8 and n 8 describing the size of the grid. The next m rows contain n numbers each. These are the initial entries of the grid. For each case, output m lines containing the state of the grid at the end of the transformation (in the same format as the input). End each case with an empty line. Sample 3 3 1 1 3 3 3 0 4 5 1 1 1 0 0 1 0 3 0 0 Sample 1 1 3 3 3 0 3 0 0 0 0 0 0 4 0 0

Problem C: Chomp We are having a chocolate eating contest. However, this is not one of those contest where the winner is the one who eats the most. No, in this contest, the winner is the contestant who is still alive at the end of the contest. The bottom left corner of a w h grid of chocolate squares has been poisoned. Contestants take turn eating a square as well all squares above and to the right of it. Of course, they must eat at least one square on their turn. x P P Figure 1: A move in the game. The square marked with P is poisoneous and the square marked with x is the one chosen to bite out of. Your task is to write a program to help you win the contest. To help us, we define winning and losing positions (or configurations or shape of chocolate) recursively as follows. A position that contains only one square of chocolate (which must be the bottom left corner) is a losing position. Otherwise, a position which can reach a losing position in one move is a winning position and a position that cannot reach a losing position in one move is a losing position. Note that position are named with respect to the player whose turn it is. The first line of input is a number c 10, the number of test cases. The first line of each test case is two numbers w, h with h 8, wh 18. The next line is a number k < 100000, the number of positions to calculate. The next k lines each consist of h numbers l 1,...,l h where l i w is the number of squares of chocolate in the ith row from the top. Furthermore, l i l i+1 for all i (since these are the only positions reachable in a game). It is now your turn. For each test case, if the position is winning, output the shape of the chocolate squares after your move (in the same format as the input). That is, output a losing position you can reach in one move. If there is more than one winning move (losing position you can reach), choose the move which lets you eat the most chocolate (of course!). If there is still a tie, choose the move which when outputted is highest in the lexicographic order. If the input position is losing (and therefore, you are sure to lose), output the bottom left square (i.e., 0 0 0... 0 ). Since you are going to lose, you might as well eat all the chocolate. Sample 5 3

4 1 1 1 3 5 0 5 4 3 1 3 1 3 4 Sample 0 1 0 0 3 4 0 1 1 1 0.1 Note 40 seconds will be allowed for generating the output for this problem instead of the usual 1 second. 4

Problem D: Polar intersecting line segments In this problem, you are asked to determine if a set of line segments intersect. The first line of input is a number c 0, the number of test cases. The first line of each test case is a number k 50000, the number of line segments. The following k lines each consist of two numbers to eight decimal places θ 1, θ with 0 < θ 1 < π and 0 < θ < π describing the line segment from (cosθ 1, sinθ 1 ) to (cosθ, sin θ ). All line segments given as input have non-zero length (i.e., the two endpoints are always different). For each test case, you should output a single line containing intersect if any two of the k lines intersect and do not intersect otherwise. The endpoints of a line are considered to be part of the line. Sample input 0 3.1415965 1.57079633 4.7138898 0 1.57079633 3.1415965 4.7138898 Sample output intersect do not intersect 5

Problem E: Letter-antiletter annihilation Letters and antiletters can sometimes annihilate each other if they are too close. For example, the antiletter a- would annilate the letter a, which we write as a+ to avoid confusion. In fact, a- does not annihilate any other letters. Similarly, b- annihilates only b+ and so on. A letter and a corresponding antiletter will annihilate each other if they are next to each other. Given a string of letters and antiletters, we would like to know what is left after all anihilations occur. Each line will consist of a string of letters and antiletters of length at most 5 10 5. Each letter or antiletter is a lower case characters followed by a symbol + or -. The input terminates with an empty line. There will be at most 30 lines in total. For each line, output the string after all anihilations have occured. The Sample input a+b+a-ba+ac+a+b+b-a-d- Sample output a+b+c+a-b-c- c+d- 0. Note 40 seconds will be allowed for generating the output for this problem instead of the usual 1 second. 6