Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 4 Ilya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is Bob, a new

image text in transcribed
image text in transcribed
Problem 4 Ilya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is "Bob", a new generation game robot. Ilya's boss wants to know his progress so far. Especially he is interested if Bob is better at playing different games than the previous model,"Alice". So now Ilya wants to compare his robots' performance in a simple game called "1-2-3". This game is similar to the "Rock-Paper-Scissors" game: both robots secretly choose a number from the set (1,2,3) and say it at the same moment. If both robots choose the same number, then it's a draw and noone gets any points. But if chosen numbers are different then one of the robots gets a point: 3 beats 2,2 beats 1 and 1 beats 3. Both robots" programs make them choose their numbers in such a way that their choice in (i +1)-th game depends only on the numbers chosen by them in i-th game. Ilya knows that the robots will play k games, Alice will choose number a in the first game, and Bob will choose b in the first game. He also knows both robots" programs and can tell what cach robot will choose depending on their choices in previous game. Ilya doesn't want to wait until robots play all k games, so he asks you to predict the number of points they will have after the final game. Input The first line contains three numbers k. a. bask10". 134, b53). Then 3 lines follow. I-th of them containing 3 numbers where Arepresents Alice's choice in the game it Alice chose i in previous game and Bob chose (I SA 53). Then 3 lines follow. I-th of them containing 3 numbers BBB where Brepresents Bob's choice in the game it Alice chose i in previous game and Bob chose ; ( 3B, 53). Output Print two numbers. First of them has to be equal to the number of points Alice will have, and second of them must be Bob's score afterk games. Examples Input 1 10 21 111 111 111 22 222 2 2 2 Output 19 Inpute2 811 221 331 313 111 211 12) Output 2 52 Input 3 511 122 222 222 122 Output 3 Note In the second example game goes like this: (1.1) (2.1) (3.2) + (1.2) (2.1) (3.2) + (1.2) (2.1) The fourth and the seventh game are won by Bob, the first game is draw and the rest are won by Alice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions