【题目链接】 http://www.lydsy.com/JudgeOnline/problem.php?id=1982

 

【题目大意】

  两个人玩游戏. 每次任选一堆,首先拿掉至少一个石头,
  然后移动任意个石子到任意堆中. 谁不能移动了,谁就输了

 

【题解】

  首先如果对于奇数堆,那么先手必胜,因为可以构建必败态
  对于偶数的情况,如果是石子堆两两相同的对称局面,则为必败态,反之必胜

 

【代码】

#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
string s[100010];
char tmp[10010];
int n;
int main(){
    scanf("%d",&n);
    if(n&1){puts("first player");return 0;}
    for(int i=1;i<=n;i++){scanf("%s",tmp);s[i]=tmp;}
    sort(s+1,s+n+1);
    for(int i=1;i<=n;i+=2)if(s[i]!=s[i+1]){puts("first player");return 0;}
    puts("second player");
    return 0;
}

相关文章:

  • 2022-02-04
  • 2021-10-25
  • 2022-12-23
  • 2021-06-07
  • 2021-10-24
  • 2021-10-26
  • 2021-10-07
  • 2021-10-20
猜你喜欢
  • 2021-08-01
  • 2022-01-24
  • 2022-01-18
  • 2021-06-05
  • 2022-01-11
  • 2022-12-23
  • 2021-05-20
相关资源
相似解决方案