Codeforces Round #169 (Div. 2), problem: (B) Little Girl and Game【久违的博弈题:可以排序的字符串回文问题】
发布日期:2021-06-29 14:26:27 浏览次数:2 分类:技术文章

本文共 527 字,大约阅读时间需要 1 分钟。


题目大意

题目中说明字母的顺序可以打乱。即是说,abb可以重新排序成bab,构成回文,此时先手胜。


题解

博弈题

由于可以重新排列,然后双方又是最优选择,我们只需要考虑一下奇数个数的字母了,看有多少种,此时连忙想到了用mao维护一下,统计个数,最后我们只要判断一下奇数个字母的个数是否为奇数或者不存在奇数个字母,那么此时先手是必赢的,反之后手赢

#include
#define endl '\n'using namespace std;const int maxn=1e3+10;char s[maxn];map
mp;map
::iterator it;int main(){
ios::sync_with_stdio(false); cin.tie(0); cin>>s; int n=strlen(s); for(int i=0;i
second&1) odd++; } if(odd&1||!odd) cout<<"First"<
学如逆水行舟,不进则退

转载地址:https://chocolate.blog.csdn.net/article/details/102667058 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Codeforces Beta Round #26 (Codeforces format), problem: (A) Almost Prime 【数组判断几乎素数】
下一篇:Codeforces Round #300, problem: (B) Quasi Binary 【贪心+二进制位数上升】

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月16日 23时01分51秒