Problem A. Game with string

Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)

Problem Description

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

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

Output

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

Sample Input

abc
1
1 2

Sample Output

Alice

注意:

这题是多组样例测试数据!!!

#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	while (cin >> s) {
	    int len = s.size();
	    int r, l, m, sum = 0;
	    cin >> m;
	    while (m--) {
	        cin >> l >> r;
	        int x = r - l + 1;
	        sum += len - x;
	    }    
		if (sum % 2 == 1) cout << "Alice\n";
	    else cout << "Bob\n";
	}
    return 0;
}