CF863C.1-2-3
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 each 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.
伊利亚就职于一家制造机器人的公司。他负责为娱乐机器人编写程序,当前的项目是新一代游戏机器人“鲍勃”(Bob)。伊利亚的老板希望了解他目前的工作进展,尤其是想了解鲍勃在各类游戏中的表现是否优于上一代模型——“爱丽丝”(Alice)。
因此,伊利亚现在希望比较两个机器人在一款名为“1-2-3”的简单游戏中的表现。该游戏类似于“石头剪刀布”:双方机器人各自秘密地从集合 {1,2,3} 中选择一个数字,并在同一时刻公布。若双方选择的数字相同,则为平局,双方均不得分;若选择的数字不同,则其中一方得一分:3 克制 2,2 克制 1,而 1 克制 3。
两个机器人的程序均使得它们在第 (i+1) 轮游戏中所选数字仅依赖于第 i 轮中双方各自所选的数字。
伊利亚已知:机器人将进行 k 轮游戏;爱丽丝在第一轮中选择数字 a,鲍勃在第一轮中选择数字 b;他还掌握了两个机器人的程序,即能根据上一轮双方的选择准确推断出本轮双方各自的选择。伊利亚不想等到机器人实际完成全部 k 轮游戏,因此请你预测最终游戏结束后双方各自获得的分数。
输入格式
The first line contains three numbers k, a, b (1 ≤ k ≤ 1018, 1 ≤ a, b ≤ 3).
Then 3 lines follow, i-th of them containing 3 numbers A__i, 1, A__i, 2, A__i, 3, where A__i, j represents Alice's choice in the game if Alice chose i in previous game and Bob chose j (1 ≤ A__i, j ≤ 3).
Then 3 lines follow, i-th of them containing 3 numbers B__i, 1, B__i, 2, B__i, 3, where B__i, j represents Bob's choice in the game if Alice chose i in previous game and Bob chose j (1 ≤ B__i, j ≤ 3).
第一行包含三个数 k、a、b(1 ≤ k ≤ 1018,1 ≤ a, b ≤ 3)。
接下来是 3 行,其中第 i 行包含 3 个数 Ai,1、Ai,2、Ai,3,其中 Ai,j 表示在上一局游戏中爱丽丝选择了 i、鲍勃选择了 j 的情况下,爱丽丝在本局游戏中的选择(1 ≤ Ai,j ≤ 3)。
再接下来是 3 行,其中第 i 行包含 3 个数 Bi,1、Bi,2、Bi,3,其中 Bi,j 表示在上一局游戏中爱丽丝选择了 i、鲍勃选择了 j 的情况下,鲍勃在本局游戏中的选择(1 ≤ Bi,j ≤ 3)。
输出格式
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 after k games.
输出两个数字。第一个数字必须等于爱丽丝在进行 k 场游戏后所获得的分数,第二个数字必须等于鲍勃的得分。
输入输出样例
输入#1
10 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2
输出#1
1 9
输入#2
8 1 1 2 2 1 3 3 1 3 1 3 1 1 1 2 1 1 1 2 3
输出#2
5 2
输入#3
5 1 1 1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2
输出#3
0 0
说明/提示
In the second example game goes like this:

The fourth and the seventh game are won by Bob, the first game is draw and the rest are won by Alice.
第二个示例游戏过程如下:

第四局和第七局由 Bob 获胜,第一局为平局,其余各局均由 Alice 获胜。
输入解题思路,AI测评打分。不知道怎么写?