AtCoder Regular Contest 137
题目链接
AtCoder Regular Contest 137
C - Distinct Numbers
Problem Statement
You are given a non-negative integer sequence of length . Here, all elements of are pairwise distinct.
Alice and Bob will play a game. They will alternately play a turn, with Alice going first. In each turn, the player does the operation below.
- Choose the largest element in at the moment, and replace it with a smaller non-negative integer. Here, all elements in must still be pairwise distinct after this operation.
The first player to be unable to do the operation loses. Determine the winner when both players play optimally.
Constraints - All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If Alice wins, print Alice; if Bob wins, print Bob.
Sample Input 1
Sample Output 1
In Alice's first turn, she may replace with , , or . If she replaces with or , Bob's move in the next turn will make Alice unable to do the operation and lose. On the other hand, if she replaces with , she can win regardless of Bob's subsequent moves. Thus, Alice wins in this input.
Sample Input 2
Sample Output 2
解题思路
博弈论
-
如果 ,先手必胜
证明:如果存在一种方案将 变为小于 的数必胜,有两种情况:1.小于 的数都不能选,则先手可以选择将 变为 使后手无数可选;2.有小于 的数可选,则先手选择一个小于 使其必胜。否则所有将 变为小于 的数必败,先手可以选择将 变为 使后手处于必败局面 -
为了不使后手处于必胜局面,先手要保证每一次操作后最大值与次最大值之间相差为 ,每次操作最大值都要减小,最终必败局面为 ,即 的奇偶性决定最后的胜者 -
时间复杂度:
代码
__EOF__

本文链接:https://www.cnblogs.com/zyyun/p/16032554.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!