목차

Yet Another Stone Game

ps
링크acmicpc.net/…
출처BOJ
문제 번호34130
문제명Yet Another Stone Game
레벨플래티넘 3
분류

게임 이론

시간복잡도O(T*n)
인풋사이즈T*n <= 300000
사용한 언어Python 3.13
제출기록66624KB / 220ms
최고기록220ms
해결날짜2025/08/21

풀이

코드

"""Solution code for "BOJ 34130. Yet Another Stone Game".

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

Tags: [game theory]
"""

import sys
from teflib import psutils


@psutils.run_n_times
def main():
    N, K = [int(x) for x in sys.stdin.readline().split()]
    a = [int(x) for x in sys.stdin.readline().split()]

    odd_count = sum(1 for a_i in a if a_i % 2 == 1)
    if K == 1:
        print('First' if sum(a) % 2 == 1 else 'Second')
    elif odd_count == 0:
        print('Second')
    elif odd_count <= K:
        print('First')
    elif odd_count == N == K + 1:
        print('Second')
    elif odd_count + 1 == N == K + 2:
        print('Second' if min(a) % 2 == 0 else 'First')
    elif odd_count == N == K + 2:
        print('First')


if __name__ == '__main__':
    main()