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
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;iscanf("%d %d",&l,&r);
        sum+=((l-1)+(len-r));
    }
    if(sum%2==0)
        cout<<"Bob"<else cout<<"Alice"<return 0;
}

你可能感兴趣的:(中石油个人训练)