Problem F. Chessboard Coloring

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

BMT 2018 Combinatorics Test Solutions March 18, 2018

Problem Set 7: Games Spring 2018

Solutions to Exercises on Page 86

Standard Sudoku point. 1 point. P a g e 1

Senior Math Circles February 10, 2010 Game Theory II

2015 ACM ICPC Southeast USA Regional Programming Contest. Division 1

Week 1. 1 What Is Combinatorics?

LEVEL I. 3. In how many ways 4 identical white balls and 6 identical black balls be arranged in a row so that no two white balls are together?

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

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

PUTNAM PROBLEMS FINITE MATHEMATICS, COMBINATORICS

The Mathematics of Playing Tic Tac Toe

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

Problem A: Ordering supermarket queues

INTERNATIONAL MATHEMATICS TOURNAMENT OF TOWNS Junior A-Level Paper, Spring 2014.

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

Problem A: Complex intersecting line segments

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

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

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

12. 6 jokes are minimal.

Take one! Rules: Two players take turns taking away 1 chip at a time from a pile of chips. The player who takes the last chip wins.

Solving Big Problems

UW-Madison ACM ICPC Individual Contest

Grade 7 & 8 Math Circles. Mathematical Games

2005 Galois Contest Wednesday, April 20, 2005

Figure 1: The Game of Fifteen

Figure 1: A Checker-Stacks Position

Game, Set, and Match Carl W. Lee September 2016

ProCo 2017 Advanced Division Round 1

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

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

We congratulate you on your achievement in reaching the second stage of the Ulpaniada Mathematics Competition and wish you continued success.

Team Round University of South Carolina Math Contest, 2018

Solutions of problems for grade R5

18.S34 (FALL, 2007) PROBLEMS ON PROBABILITY

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

Contest 1. October 20, 2009

4th Pui Ching Invitational Mathematics Competition. Final Event (Secondary 1)

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

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

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

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

Subtraction games with expandable subtraction sets

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

Sept. 26, 2012

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

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

(b) In the position given in the figure below, find a winning move, if any. (b) In the position given in Figure 4.2, find a winning move, if any.

Problem A. Jumbled Compass

Irish Collegiate Programming Contest Problem Set

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

CS 491 CAP Intro to Combinatorial Games. Jingbo Shang University of Illinois at Urbana-Champaign Nov 4, 2016

On Modular Extensions to Nim

Mathematics. Programming

Olympiad Combinatorics. Pranav A. Sriram

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

Counters in a Cup In and Out. The student sets up the cup, drops the counters on it, and records how many landed in and out of the cup.

Junior Circle Games with coins and chessboards

Counting Things. Tom Davis March 17, 2006

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

4th Bay Area Mathematical Olympiad

TOURNAMENT ROUND. Round 1

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

UCF Local Contest August 31, 2013

Problem Solving By Cynthia Northrup

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

NCPC 2007 Problem C: Optimal Parking 7. Problem C. Optimal Parking

OCTAGON 5 IN 1 GAME SET

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

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

# 1. As shown, the figure has been divided into three identical parts: red, blue, and green. The figures are identical because the blue and red

PRIMES STEP Plays Games

Counting Things Solutions

Crossing Game Strategies

The 2013 British Informatics Olympiad

ACM International Collegiate Programming Contest 2010

Coin Cappers. Tic Tac Toe

Grade 6 Math Circles. Math Jeopardy

GENERALIZATION: RANK ORDER FILTERS

Non-attacking queens on a triangle

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

Junior Circle Meeting 5 Probability. May 2, ii. In an actual experiment, can one get a different number of heads when flipping a coin 100 times?

Distribution of Aces Among Dealt Hands

On Variations of Nim and Chomp

NIM Games: Handout 1

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

Problem A. Worst Locations

CS 32 Puzzles, Games & Algorithms Fall 2013

Surreal Numbers and Games. February 2010

Introduction to Spring 2009 Artificial Intelligence Final Exam

A Winning Strategy for the Game of Antonim

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

of Nebraska - Lincoln

F rederic F Pool. V o l u m e O n e

Game 0: One Pile, Last Chip Loses

MATHEMATICS LEVEL: (B - Γ Λυκείου)

BmMT 2015 Puzzle Round November 7, 2015

THINGS TO DO WITH A GEOBOARD

Transcription:

Problem F Chessboard Coloring You have a chessboard with N rows and N columns. You want to color each of the cells with exactly N colors (colors are numbered from 0 to N 1). A coloring is valid if and only if no row or no columns contains a duplicate color. That means in the final coloring each cell should be colored by a color from 0 to N 1. No row will contain two cells of the same color and same for the no column. Your friend already colored some of the cells in the top left corner (cells that are in the first R row and in the first C columns). Your job is to color the rest of the cells or tell it is impossible to color. starts with an integer T(1 T 50), the number of test cases. Each test case starts with a line containing integers N(1 T 50), R (0 R N) and C (0 C N). Each of the next R line contains C integers in each line. The j th integer in the i th line indicates the color of the cell located at row i and column j. The initial coloring will be always valid. That means No row or column will have duplicate integers. The initial colors are between 0 to N 1 inclusive. For each test case output YES when it is possible to color the rest of the cells or NO otherwise. YES 2 2 NO 1 2 YES 2 0 2 0 1 2 2 0 1 1 1 0

Problem G Half Nim Half Nim is a 2 player game in which player take turns removing stones from distinct heaps. There are N heaps with a 1,a 2,,a n number of stones. The player is permitted to take any positive number of stones from one pile for a move but no more than half. The player who cannot make his move loses. Given the number of stones in the piles you are to determine if the first player has a winning strategy. You can assume that both of the players play perfectly. starts with an integer T(1 T 100), the number of test cases. Each test case starts with a line containing N(1 N 100) the number of heaps. Next line contains N integers a 1,a 2,,a n. These numbers are between 1 and 2*10 18 inclusive. For each test case output contains a line in the format Case #x: M where x is the case number (starting from 1) and M will be YES if the first player wins and NO if the first player cannot win. 2 1 2 2 6 Case #1: NO Case #2: YES Case #: NO

Problem H Point inside a Polygon Given a test point and the vertices of a simple polygon, vertices, determine if the test point is in the interior, in the exterior or on the boundary of the polygon. For simplicity, all sides of the polygon will be horizontal or vertical, and the vertices and the test point will all be at integer coordinates. A simple polygon is a polygon that may or may not be convex, but self intersection is not allowed. Not even at a single point. First line of the input contains T the number of test cases. Each test case starts with a line containing N the number of points of the polygon. N is between and 100 inclusive. Each of the next N line contains 2 integers X and Y the co ordinate of a vertex of the polygon. The vertices will be given in order. No three consecutive points will be collinear. The final line will contain 2 integers TX and TY denoting the coordinate of the test point. All the co ordinates are between 1000 to +1000 inclusive. For each test case, output INTERIOR if the point is inside the polygon, EXTERIOR if the point is outside the polygon and BOUNDARY if the point is on the boundary of the polygon. 0 10 10 10 1 5 5 0 10 10 10 1 10 15 0 10 10 10 1 5 10 10 0-2 -2 0-1 0-1 2 2 1 0 1 1 2 INTERIOR EXTERIOR BOUNDARY EXTERIOR

Problem I Spiral Consider all positive integers written in the following manner (you can imagine an infinite spiral). 21 22 2 2 25 26 20 7 8 9 10... 19 6 1 2 11... 18 5 12... 17 16 15 1 1... You task is to determine the position (row,column) of a given number N, assuming that the center (number 1) has position (0,0). Rows are numbered from top to bottom, columns are numbered from left to right (for example, number is at (1,1)). Your program should ouput a string containing the position of N in form (R,C) where R is the row and C is the column. R and C must not contain any leading zeroes. The first line of the input gives an integer T, which is the number of test cases. Each test case contains an integer N (1 N<2^1). For each test case, output the position as described above. See sample output for further clarification. 7 2 7 17 2 80 76509 (0,1) (1,1) (-1,-1) (2,-2) (-2,1) (-1,) (-7,221)

Problem J Guitar Game You have been invited to a TV game show where you will play against another contestant to win free guitars. At the start of the game, there are n guitar cases arranged in a circle, each of which contains a single guitar. You make the first move by choosing one guitar and removing it from its case. The other player then chooses a guitar and removes it from its case. At this point, there might be one or two groups, where a group is defined as a maximal contiguous set of non empty cases. You continue to take turns choosing guitars, and on each turn, the current player chooses exactly one guitar from each group. The game ends when all the guitars have been chosen. Each player gets to keep all the guitars that he chooses during the game. Your goal is to maximize the total value of the guitars you choose. The guitars in the circle are numbered 0 to n 1 in clockwise order (guitar 0 is next to guitar n 1). Given the values of the guitars, compute the maximum possible total value you can get, assuming your opponent plays a perfect strategy. First line of the input contains T the number of test cases. Each test case starts with a line containing N, the number of guitars. N is between 2 and 100 inclusive. Next line contains N integers denoting the values of the guitars. All the values are between 1 and 10000 inclusive. For each test case output the maximum possible total value you can get, assuming your opponent plays a perfect strategy. 6 5 1 5 5 8 8 2 1 1 2 1 8 1 5 12 5 10 5 7 8 8 2 2 8 2 2 Sample 10 12 12 22 1 16

Problem K Marbles in a Bag Your friend Psycho Sid has challenged you to a game. He has a bag containing R red marbles and B blue marbles. There will be an odd number of marbles in the bag, and you go first. On your turn, you reach into the bag and remove a random marble from the bag; each marble may be selected with equal probability. After your turn is over, Sid will reach into the bag and remove a blue marble; if there is no blue marble for Sid to remove, then he wins. If the final marble removed from the bag is blue, you will win. Otherwise, Sid wins. Given the number of red and blue marbles in the bag, determine the probability that you win the game. The first line of the input gives an integer T, which is the number of test cases. Each test case contains 2 integers R and B. Both R and B are between 0 and 000 inclusive. R+B will always be odd. For each case, output the probability that you win the game. digits after the decimal. 1 2 2 2 5 11 Sample 0. 0.1 0.228571 0.1218