목차

String Game

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()