| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 11307 |
| 문제명 | String Game |
| 레벨 | 골드 1 |
| 분류 |
게임 이론 |
| 시간복잡도 | O(T*n) |
| 인풋사이즈 | t*n <= 500000 |
| 사용한 언어 | Python 3.11 |
| 제출기록 | 32096KB / 44ms |
| 최고기록 | 44ms |
| 해결날짜 | 2023/07/22 |
"""Solution code for "BOJ 11307. String Game".
- Problem link: https://www.acmicpc.net/problem/11307
- Solution link: http://www.teferi.net/ps/problems/boj/11307
Tags: [game theory]
"""
import sys
def main():
N = int(sys.stdin.readline())
for _ in range(N):
initial, target = sys.stdin.readline().split()
remove_count = len(initial) - len(target)
if remove_count % 2 == 0:
is_win_pos = initial[remove_count // 2 :].startswith(target) or (
initial[remove_count // 2 - 1 :].startswith(target)
and initial[remove_count // 2 + 1 :].startswith(target)
)
else:
is_win_pos = initial[remove_count // 2 :].startswith(target) and (
initial[remove_count // 2 + 1 :].startswith(target)
)
print('Alice' if is_win_pos else 'Bob')
if __name__ == '__main__':
main()