UPC 组队训练 A: Game with string

问题 A: Game with string
时间限制: 2 Sec 内存限制: 256 MB
提交: 81 解决: 45
[提交] [状态] [讨论版] [命题人:admin]
题目描述
Alice and Bob are playing a game with string. Given a string S = S1…Sn. They choose m substrings from S, the ith substring is SLi …SRi .
Alice and Bob play alternately, with Alice going first.
On a player’s turn, this player can add a character into one of those m substrings, but the character should be added in the front or in the end, and the new string should still be a substring of S.
The player unable to make a valid move loses the game. Who will be the winner if both players move optimally?

输入
Input is given from Standard Input in the following format:
S
m
L1 R1
L2 R2
.
.
Lm Rm
Constraints
1 ≤ |S| ≤ 100000
1 ≤ m ≤ 100000
1 ≤ Li ≤ Ri ≤ |S|(1 ≤ i ≤ m)
characters in S are lowercase

输出
Print one line denotes the answer.
If Alice can win, output “Alice”, otherwise “Bob”.

样例输入
abc
1
1 2

样例输出
Alice

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100005];
    scanf("%s",s);
    int len=strlen(s);
    int m;cin>>m;
    int l,r;int sum=0;
    for(int i=0;i<m;i++)
    {
        scanf("%d %d",&l,&r);
        sum+=((l-1)+(len-r));
    }
    if(sum%2==0)
        cout<<"Bob"<<endl;
    else cout<<"Alice"<<endl;
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值