-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholliePS-252.cpp
61 lines (59 loc) · 1.17 KB
/
olliePS-252.cpp
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
55
56
57
58
59
60
61
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ull unsigned long long
#define flash() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void solution()
{
string str;
cin >> str;
ll n = str.length();
if(n % 2 == 0)
{
ll as = 0;
for(char ch : str)
{
as += (ch - 'a') + 1;
}
cout << "Alice" << " " << as << endl;
return;
}
if(str[0] >= str[n-1])
{
ll as = 0 , bs = (str[n-1] - 'a') + 1;
for(ll i = 0 ; i < n-1 ; i++)
{
as += (str[i] - 'a') + 1;
}
if(as > bs)
{
cout << "Alice" << " " << (as - bs) << endl;
return;
}
cout << "Bob" << " " << (bs - as) << endl;
return;
}
ll as = 0 , bs = (str[0] - 'a') + 1;
for(ll i = 1 ; i < n ; i++)
{
as += (str[i] - 'a') + 1;
}
if(as > bs)
{
cout << "Alice" << " " << (as - bs) << endl;
return;
}
cout << "Bob" << " " << (bs - as) << endl;
return;
}
int main()
{
flash();
ll t;
cin >> t;
while(t--)
{
solution();
}
return 0;
}