Fall 2018 #11 Games and Nimbers. A. Game. 0.5 seconds, 64 megabytes

Similar documents
Test 2. ECON3161, Game Theory. Tuesday, November 6 th

Dynamic Optimization. Assignment 1. Sasanka Nagavalli January 29, 2013 Robotics Institute Carnegie Mellon University

problems palette of David Rock and Mary K. Porter 6. A local musician comes to your school to give a performance

Review: Our Approach 2. CSC310 Information Theory

UNIT 11 TWO-PERSON ZERO-SUM GAMES WITH SADDLE POINT

Old text. From Through the Looking Glass by Lewis Carroll. Where is the setting of this place? Describe in your own words.

To: Professor Avitabile Date: February 4, 2003 From: Mechanical Student Subject: Experiment #1 Numerical Methods Using Excel

Calculation of the received voltage due to the radiation from multiple co-frequency sources

EMA. Education Maintenance Allowance (EMA) Financial Details Form 2017/18. student finance wales cyllid myfyrwyr cymru.

STAR POWER BOM/BOQ SETTING IDEA 1 - TWIST & SHOUT

NATIONAL RADIO ASTRONOMY OBSERVATORY Green Bank, West Virginia SPECTRAL PROCESSOR MEMO NO. 25. MEMORANDUM February 13, 1985

Introduction to Coalescent Models. Biostatistics 666 Lecture 4

ALICE AND BOB GO TO DINNER: A VARIATION ON MÉNAGE

Ultimate X Bonus Streak Analysis

Introduction to Coalescent Models. Biostatistics 666

PREVIEW. Phonics Matching Games. Created by Top Notch Teaching Card Games

N( E) ( ) That is, if the outcomes in sample space S are equally likely, then ( )

Priority based Dynamic Multiple Robot Path Planning

Generalized Incomplete Trojan-Type Designs with Unequal Cell Sizes

Problem Set 7: Games Spring 2018

Networks. Backpropagation. Backpropagation. Introduction to. Backpropagation Network training. Backpropagation Learning Details 1.04.

Passive Filters. References: Barbow (pp ), Hayes & Horowitz (pp 32-60), Rizzoni (Chap. 6)

Wild Animals. Lesson at a Glance. Animals. Lesson Objectives. Lesson Plan. Bible Story Text. Bible Truth. Lesson 3

Digital Transmission

Prevention of Sequential Message Loss in CAN Systems

Tile Values of Information in Some Nonzero Sum Games

Machine Learning in Production Systems Design Using Genetic Algorithms

Meredith Sinclair s DIY Clothespin Xmas Tree

The Byzantine Generals Problem

PRO- CRIMPER* III Hand Crimping

PRO- CRIMPER* III Hand

PRACTICAL, COMPUTATION EFFICIENT HIGH-ORDER NEURAL NETWORK FOR ROTATION AND SHIFT INVARIANT PATTERN RECOGNITION. Evgeny Artyomov and Orly Yadid-Pecht

Graph Method for Solving Switched Capacitors Circuits

PRO- CRIMPER III Hand Crimping Tool Assembly DESCRIPTION (Figures 1 and 2)

Chinese Remainder. Discrete Mathematics Andrei Bulatov

Shunt Active Filters (SAF)

A Lower Bound for τ(n) of Any k-perfect Numbers

onlinecomponents.com

Walsh Function Based Synthesis Method of PWM Pattern for Full-Bridge Inverter

Sorting signed permutations by reversals, revisited

High Speed ADC Sampling Transients

Network Theory. EC / EE / IN. for

aperture David Makovoz, 30/01/2006 Version 1.0 Table of Contents

PRO- CRIMPER* III Hand Crimping

Guidelines for CCPR and RMO Bilateral Key Comparisons CCPR Working Group on Key Comparison CCPR-G5 October 10 th, 2014

A Comparison of Two Equivalent Real Formulations for Complex-Valued Linear Systems Part 2: Results

PRO- CRIMPER* III Hand

1. REVIEW 2. DELIVERY SET

VRT014 User s guide V0.8. Address: Saltoniškių g. 10c, Vilnius LT-08105, Phone: (370-5) , Fax: (370-5) ,

PRO-CRIMPER* III Hand Crimping Tool Assembly with Die AssemblY

Figure 1. DC-DC Boost Converter

PRO- CRIMPER III Hand Crimping Tool Assembly INSTALLATION AND REMOVAL OF DIE SET AND LOCATOR ASSEMBLY (Figure 2)

A NSGA-II algorithm to solve a bi-objective optimization of the redundancy allocation problem for series-parallel systems

Chapter 1. On-line Choice of On-line Algorithms. Yossi Azar Andrei Z. Broder Mark S. Manasse

The Complexity of Playing Durak

A Novel Optimization of the Distance Source Routing (DSR) Protocol for the Mobile Ad Hoc Networks (MANET)

Webinar Series TMIP VISION

Comparison of Two Measurement Devices I. Fundamental Ideas.

Mesh Equations. Introduction

ANNUAL OF NAVIGATION 11/2006

PRO-CRIMPER* III Hand. with Die Assembly OCT 11 Rev C. Pivot Pin. Die Assembly Moving Jaw CONTACT FAMILY SIZE (AWG)

4.3- Modeling the Diode Forward Characteristic

PRO- CRIMPER* III Hand Crimping

Online Reporting. Online Reporting. A step-by-step guide. Important information for churches, schools and organisations

Steps for Starting a WRO Robotics Program

Control Chart. Control Chart - history. Process in control. Developed in 1920 s. By Dr. Walter A. Shewhart

Ensemble Evolution of Checkers Players with Knowledge of Opening, Middle and Endgame

antenna antenna (4.139)

MTBF PREDICTION REPORT

1 GSW Multipath Channel Models

PERFORMANCE EVALUATION OF BOOTH AND WALLACE MULTIPLIER USING FIR FILTER. Chirala Engineering College, Chirala.

Integer Programming. P.H.S. Torr Lecture 5. Integer Programming

IEE Electronics Letters, vol 34, no 17, August 1998, pp ESTIMATING STARTING POINT OF CONDUCTION OF CMOS GATES

Space Time Equalization-space time codes System Model for STCM

29. Network Functions for Circuits Containing Op Amps

PRO- CRIMPER* III Hand

Rational Secret Sharing without Broadcast

Figure.1. Basic model of an impedance source converter JCHPS Special Issue 12: August Page 13

PRO-CRIMPER* III Hand Crimping Tool Assembly with Die Assembly

Coordinating the Motions of Multiple Robots with Specified Trajectories

MANY applications involve robots that are deployed in a. Multi-Robot Data Gathering Under Buffer Constraints and Intermittent Communication

Electricity Network Reliability Optimization

Arterial Travel Time Estimation Based On Vehicle Re-Identification Using Magnetic Sensors: Performance Analysis

Nonlinear Complex Channel Equalization Using A Radial Basis Function Neural Network

NEW ALGORITHM FOR ATTITUDE DETERMINATION USING GPS SIGNALS

current activity shows on the top right corner in green. The steps appear in yellow

THE GENERATION OF 400 MW RF PULSES AT X-BAND USING RESONANT DELAY LINES *

User s manual. Digital control relay SNI

I' I THE GAME OF CHECKERS SOME STUDIES IN MACHINE LEARNING USING. should eventually eliminate the need for much of this detailed programming

Discussion on How to Express a Regional GPS Solution in the ITRF

ph fax

Instruction Sheet ROTA- CRIMP* Hand Crimping Tools and

SDE PEW- 12 Hand Tool

... -J to send radio signals through the air, how modulation , IJ."~ UNITED STATES~~ FREQUENCY ALLOCATIONS

STRUCTURE ANALYSIS OF NEURAL NETWORKS

STATISTICS. is given by. i i. = total frequency, d i. = x i a ANIL TUTORIALS. = total frequency and d i. = total frequency, h = class-size

A Simple Satellite Exclusion Algorithm for Advanced RAIM

Adaptive Modulation for Multiple Antenna Channels

Multi-Robot Map-Merging-Free Connectivity-Based Positioning and Tethering in Unknown Environments

Figure 1. DC-DC Boost Converter

Transcription:

5-95 Fall 08 # Games and Nmbers A. Game 0.5 seconds, 64 megabytes There s a legend n the IT Cty college. A student that faled to answer all questons on the game theory exam s gven one more chance by hs professor. The student has to play a game wth the professor. The game s played on a square feld consstng of n n cells. Intally all cells are empty. On each turn a player chooses and pant an empty cell that has no common sdes wth prevously panted cells. Adjacent corner of panted cells s allowed. On the next turn another player does the same, then the frst one and so on. The player wth no cells to pant on hs turn loses. The professor have chosen the feld sze n and allowed the student to choose to be the frst or the second player n the game. What should the student choose to wn the game? Both players play optmally. 8 The only lne of the contans one nteger n ( n 0 ) the sze of the feld. number, f the player makng the frst turn wns when both players play optmally, otherwse prnt number.

B. Industral Nm seconds, 64 megabytes There are n stone quarres n Petrograd. Each quarry owns m dumpers ( n). It s known that the frst dumper of the -th quarry has x stones n t, the second dumper has x + stones n t, the thrd has x +, and the m-th dumper (the last for the -th quarry) has x + m - stones n t. Two olgarchs play a well-known game Nm. Players take turns removng stones from dumpers. On each turn, a player can select any dumper and remove any non-zero amount of stones from t. The player who cannot take a stone loses. Your task s to fnd out whch olgarch wll wn, provded that both of them play optmally. The olgarchs asked you not to reveal ther names. So, let's call the one who takes the frst stone «tolk» and the other one «bolk». The frst lne of the contans one nteger number n ( n 05 ) the amount of quarres. Then there follow n lnes, each of them contans two space-separated ntegers x and m ( x, m 06 ) the amount of stones n the frst dumper of the -th quarry and the number of dumpers at the -th quarry. «tolk» f the olgarch who takes a stone frst wns, and «bolk» otherwse. 3 tolk 4 bolk

C. Game of Stones 3 seconds, 56 megabytes Sam has been teachng Jon the Game of Stones to sharpen hs mnd and help hm devse a strategy to fght the whte walkers. The rules of ths game are qute smple: The game starts wth n ples of stones ndexed from to n. The -th ple contans s stones. The players make ther moves alternatvely. A move s consdered as removal of some number of stones from a ple. Removal of 0 stones does not count as a move. The player who s unable to make a move loses. Now Jon beleves that he s ready for battle, but Sam does not thnk so. To prove hs argument, Sam suggested that they play a modfed verson of the game. In ths modfed verson, no move can be made more than once on a ple. For example, f 4 stones are removed from a ple, 4 stones cannot be removed from that ple agan. Sam sets up the game and makes the frst move. Jon beleves that Sam s just tryng to prevent hm from gong to battle. Jon wants to know f he can wn f both play optmally. Frst lne conssts of a sngle nteger n ( n 06 ) the number of ples. Each of next n lnes contans an nteger s ( s 60) the number of stones n -th ple. Prnt a sngle lne contanng "YES" (wthout quotes) f Jon wns, otherwse prnt "NO" (wthout quotes) 5 NO YES In the frst case, Sam removes all the stones and Jon loses. In second case, the followng moves are possble by Sam: In each of these cases, last move can be made by Jon to wn the game as follows:

D. Sagheer and Apple Tree seconds, 56 megabytes Sagheer s playng a game wth hs best frend Solman. He brought a tree wth n nodes numbered from to n and rooted at node. The -th node has a apples. Ths tree has a specal property: the lengths of all paths from the root to any leaf have the same party (.e. all paths have even length or all paths have odd length). Sagheer and Solman wll take turns to play. Solman wll make the frst move. The player who can't make a move loses. In each move, the current player wll pck a sngle node, take a non-empty subset of apples from t and do one of the followng two thngs:. eat the apples, f the node s a leaf.. move the apples to one of the chldren, f the node s non-leaf. Before Solman comes to start playng, Sagheer wll make exactly one change to the tree. He wll pck two dfferent nodes u and v and swap the apples of u wth the apples of v. Can you help Sagheer count the number of ways to make the swap (.e. to choose u and v) after whch he wll wn the game f both players play optmally? (u, v) and (v, u) are consdered to be the same par. 5 The frst lne wll contan one nteger n ( n 0 ) the number of nodes n the apple tree. The second lne wll contan n ntegers a, a,..., a ( a 0 ) the number of apples on each node of the tree. The thrd lne wll contan n - ntegers p, p 3,..., p n ( p n) the parent of each node of the tree. Node has parent p (for n). Node s the root of the tree. n It s guaranteed that the descrbes a vald tree, and the lengths of all paths from the root to any leaf wll have the same party. On a sngle lne, prnt the number of dfferent pars of nodes (u, v), u v such that f they start playng after swappng the apples of both nodes, Sagheer wll wn the game. (u, v) and (v, u) are consdered to be the same par. 7

3 3 3 3 0 8 7 5 4 3 4 4 5 6 4 In the frst sample, Sagheer can only wn f he swapped node wth node 3. In ths case, both leaves wll have apples. If Solman makes a move n a leaf node, Sagheer can make the same move n the other leaf. If Solman moved some apples from a root to a leaf, Sagheer wll eat those moved apples. Eventually, Solman wll not fnd a move. In the second sample, There s no swap that wll make Sagheer wn the game. Note that Sagheer must make the swap even f he can wn wth the ntal tree.

E. Permutaton Game second, 56 megabytes After a long day, Alce and Bob decded to play a lttle game. The game board conssts of cells n a straght lne, numbered from to n, where each cell contans a number a between and n. Furthermore, no two cells contan the same number. A token s placed n one of the cells. They take alternatng turns of movng the token around the board, wth Alce movng frst. The current player can move from cell to cell only f the followng two condtons are satsfed: the number n the new cell j must be strctly larger than the number n the old cell (.e. a j > a ), and the dstance that the token travels durng ths turn must be a multple of the number n the old cell (.e. j mod a = 0). Whoever s unable to make a move, loses. For each possble startng poston, determne who wns f they both play optmally. It can be shown that the game s always fnte,.e. there always s a wnnng strategy for one of the players. The frst lne contans a sngle nteger n ( n 0 5 ) the number of numbers. The second lne contans n ntegers a, a,, a n ( a n). Furthermore, there are no par of ndces such that a a j. Prnt s a strng of n characters, where the -th character represents the outcome of the game f the token s ntally placed n the cell. If Alce wns, then s has to be equal to "A"; otherwse, s has to be equal to "B". = 8 3 6 5 4 7 8 BAAAABAB j n j 5 3 5 0 9 7 3 5 8 4 6 4 ABAAAABBBAABAAB In the frst sample, f Bob puts the token on the number (not poston): : Alce can move to any number. She can wn by pckng 7, from whch Bob has no move. 3 5 5 8 3 wns, as Bob has only a move to 4, from whch Alce can move to 8. 3: Alce can only move to 4, after whch Bob wns by movng to 8. 4, 5, or 6: Alce wns by movng to 8. 7, 8: Alce has no move, and hence she loses mmedately. : Alce can move to and. Upon movng to, Bob can wn by movng to. If she chooses nstead, she

F. Playng wth Strng seconds, 56 megabytes Two people play the followng strng game. Intally the players have got some strng s. The players move n turns, the player who cannot make a move loses. Before the game began, the strng s wrtten on a pece of paper, one letter per cell. An example of the ntal stuaton at s = "abacaba" A player's move s the sequence of actons:. The player chooses one of the avalable peces of paper wth some strng wrtten on t. Let's denote t s t. Note that ntally, only one pece of paper s avalable.. The player chooses n the strng t = t t... t character n poston ( t ) such that for some postve t nteger l (0 < - l; + l t ) the followng equatons hold: t = t, t = t,..., t = t. - + - + - l + l 3. Player cuts the cell wth the chosen character. As a result of the operaton, he gets three new peces of paper, the frst one wll contan strng tt... t - t, the thrd one contans strng t t... t. + + t, the second one wll contan a strng consstng of a sngle character An example of makng acton ( = 4) wth strng s = «abacaba» Your task s to determne the wnner provded that both players play optmally well. If the frst player wns, fnd the poston of character that s optmal to cut n hs frst move. If there are multple postons, prnt the mnmal possble one. The frst lne contans strng s ( s 5000). It s guaranteed that strng s only contans lowercase Englsh letters. If the second player wns, prnt n the sngle lne "Second" (wthout the quotes). Otherwse, prnt n the frst lne "Frst" (wthout the quotes), and n the second lne prnt the mnmal possble wnnng move nteger ( s ). abacaba Frst abcde Second In the frst sample the frst player has multple wnnng moves. But the mnmum one s to cut the character n poston. In the second sample the frst player has no avalable moves.