CF575H.Bots
普及+/提高
通过率:0%
时间限制:1.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based. In each turn, one of the players makes a move (it doesn’t matter which player, it's possible that players turns do not alternate).
Algorithm for bots that Sasha and Ira are developing works by keeping track of the state the game is in. Each time either bot makes a move, the state changes. And, since the game is very dynamic, it will never go back to the state it was already in at any point in the past.
Sasha and Ira are perfectionists and want their algorithm to have an optimal winning strategy. They have noticed that in the optimal winning strategy, both bots make exactly N moves each. But, in order to find the optimal strategy, their algorithm needs to analyze all possible states of the game (they haven’t learned about alpha-beta pruning yet) and pick the best sequence of moves.
They are worried about the efficiency of their algorithm and are wondering what is the total number of states of the game that need to be analyzed?
萨莎和伊拉开是两位最好的朋友。但她们不仅仅是朋友,还是软件工程师,也是人工智能领域的专家。她们正在为两个机器人开发一款双人游戏的算法。该游戏是合作型的、回合制的。在每个回合中,其中一名玩家进行一次移动(具体由哪位玩家移动并不重要,且玩家的回合未必交替进行)。
萨莎和伊拉开所开发的机器人算法通过持续追踪游戏所处的状态来工作。每当任一机器人执行一次移动时,游戏状态就会发生变化;而且,由于游戏具有极强的动态性,其状态绝不会回到过去任意时刻曾出现过的任何一个状态。
萨莎和伊拉开是完美主义者,希望她们的算法能实现最优获胜策略。她们注意到,在最优获胜策略中,两个机器人都恰好各自执行 N 次移动。然而,为了找到该最优策略,她们的算法需要分析游戏的所有可能状态(她们尚未学习 alpha-beta 剪枝技术),并从中选出最优的移动序列。
她们担心算法的效率,因而想知道:总共需要分析多少个游戏状态?
输入格式
The first and only line contains integer N.
- 1 ≤ N ≤ 106
第一行且唯一一行包含整数 N。
- 1 ≤ N ≤ 106
输出格式
Output should contain a single integer – number of possible states modulo 109 + 7.
输出应为一个整数——可能的状态数对 109+7 取模的结果。
输入输出样例
输入#1
2
输出#1
19
说明/提示
Start: Game is in state A.
- Turn 1: Either bot can make a move (first bot is red and second bot is blue), so there are two possible states after the first turn – B and C.
- Turn 2: In both states B and C, either bot can again make a turn, so the list of possible states is expanded to include D, E, F and G.
- Turn 3: Red bot already did N=2 moves when in state D, so it cannot make any more moves there. It can make moves when in state E, F and G, so states I, K and M are added to the list. Similarly, blue bot cannot make a move when in state G, but can when in D, E and F, so states H, J and L are added.
- Turn 4: Red bot already did N=2 moves when in states H, I and K, so it can only make moves when in J, L and M, so states P, R and S are added. Blue bot cannot make a move when in states J, L and M, but only when in H, I and K, so states N, O and Q are added.
Overall, there are 19 possible states of the game their algorithm needs to analyze.

开始:游戏处于状态 A。
- 第 1 回合:任一机器人均可行动(第一个机器人为红色,第二个为蓝色),因此第一回合后可能的状态有两个——B 和 C。
- 第 2 回合:在状态 B 和 C 中,任一机器人均可再次行动,因此可能的状态集合扩展为包含 D、E、F 和 G。
- 第 3 回合:红色机器人在状态 D 中已执行 N=2 次行动,因此在此状态下无法再行动;它可在状态 E、F 和 G 中行动,故新增状态 I、K 和 M。类似地,蓝色机器人在状态 G 中无法行动,但在状态 D、E 和 F 中可以行动,因此新增状态 H、J 和 L。
- 第 4 回合:红色机器人在状态 H、I 和 K 中均已执行 N=2 次行动,因此仅能在状态 J、L 和 M 中行动,故新增状态 P、R 和 S。蓝色机器人在状态 J、L 和 M 中无法行动,仅能在状态 H、I 和 K 中行动,因此新增状态 N、O 和 Q。
综上,其算法需分析的游戏状态总数为 19 种。

输入解题思路,AI测评打分。不知道怎么写?