Blame view

P35957_en/S001-AC.cc 723 Bytes
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <sstream>

using namespace std;

int strToInt(string str)
{
	stringstream sstream;
	int ret;
	sstream.str(str);
	sstream >> ret;
	return ret;
}

bool middleNumberIsEqual(string a, string b)
{
	return (a[a.length()/2] == b[b.length()/2]);
}

int main()
{
	int n, turn = 0;
	string a,b;
	cin >> n;
	cin >> a;
	for(int i = 1; i < 2*n; i++)
	{
		turn++;
		cin >> b;
		if(!(a.length() % 2))
		{
			cout << "B" << endl;
			return 0;
		}
		else if(!(b.length() % 2))
		{
			cout << "A" << endl;
			return 0;
		}
		if(!middleNumberIsEqual(a,b))
		{
			if(turn % 2)
			{
				cout << "A" << endl;
				return 0;
			}
			cout << "B" << endl;
			return 0;
		}
		a = b;
	}
	cout << "=" << endl;
	return 0;
}