목차

Polygons

ps
링크acmicpc.net/…
출처BOJ
문제 번호8055
문제명Polygons
레벨실버 3
분류

게임이론

시간복잡도O(1)
사용한 언어Python 3.11
제출기록31120KB / 40ms
최고기록40ms
해결날짜2023/12/15

풀이

코드

"""Solution code for "BOJ 8055. Polygons".

- Problem link: https://www.acmicpc.net/problem/8055
- Solution link: http://www.teferi.net/ps/problems/boj/8055

Tags: [game theory]
"""

import sys


def is_outer_edge(x, y, n):
    return abs(x - y) in (1, n - 1)


def main():
    n = int(sys.stdin.readline())
    a, b, c = [int(x) for x in sys.stdin.readline().split()]
    if (
        sum(1 for x, y in ((a, b), (b, c), (c, a)) if is_outer_edge(x, y, n))
        == 2
    ):
        print('TAK')
    else:
        print('TAK' if n % 2 == 0 else 'NIE')


if __name__ == '__main__':
    main()