| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 35127 |
| 문제명 | Game of Names |
| 레벨 | 플래티넘 3 |
| 분류 |
게임이론 |
| 시간복잡도 | O(∑n) |
| 인풋사이즈 | ∑n <= 2*10^5 |
| 사용한 언어 | Python 3.13 |
| 제출기록 | 32412KB / 224ms |
| 최고기록 | 224ms |
| 해결날짜 | 2026/01/17 |
"""Solution code for "BOJ 35127. Game of Names".
- Problem link: https://www.acmicpc.net/problem/35127
- Solution link: http://www.teferi.net/ps/problems/boj/35127
Tags: [game theory]
"""
import sys
from teflib import psutils
@psutils.run_n_times
def main():
n = int(sys.stdin.readline())
s = sys.stdin.readline().rstrip()
if s.count('.') == n:
print('bob' if n > 1 else 'alice')
return
left, right = None, None
if s[0] != '.':
left = s[0]
elif s[1] != '.':
left = 'a' if s[1] == 'b' else 'b'
if s[-1] != '.':
right = s[-1]
elif s[-2] != '.':
right = 'a' if s[-2] == 'b' else 'b'
if left is None and right is None:
left, right = 'a', 'b'
elif left is None:
left = 'a'
elif right is None:
right = 'a'
adv = s.count('b') - s.count('a')
if left == right:
adv += 1 if left == 'a' else -1
print('alice' if adv > 0 else 'bob')
if __name__ == '__main__':
main()