사용자 도구

사이트 도구


ps:problems:boj:2207

가위바위보

ps
링크acmicpc.net/…
출처BOJ
문제 번호2207
문제명가위바위보
레벨플래티넘 4
분류

2-sat

시간복잡도O(n+m)
인풋사이즈n<=10000, m<=10000
사용한 언어Python
제출기록35000KB / 124ms
최고기록96ms
해결날짜2022/11/03
태그

[라이]2-SAT 문제

풀이

  • 기본적인 2-SAT문제. 사실상 2-SAT - 3 에서 문제 시나리오만 추가한 것과 같다. (인풋 형식도 동일하다보니,.)
  • 시간복잡도는 O(n+m)

코드

"""Solution code for "BOJ 2207. 가위바위보".

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

Tags: [2-sat]
"""

import sys
from teflib import twosat


def main():
    N, M = [int(x) for x in sys.stdin.readline().split()]
    two_sat = twosat.TwoSat(M)
    for _ in range(N):
        x, y = [int(x) for x in sys.stdin.readline().split()]
        x = x - 1 if x > 0 else x
        y = y - 1 if y > 0 else y
        two_sat.x_or_y(x, y)

    print('^_^' if two_sat.is_satisfiable() else 'OTL')


if __name__ == '__main__':
    main()

토론

댓글을 입력하세요:
F V D C A
 
ps/problems/boj/2207.txt · 마지막으로 수정됨: 2022/11/03 16:49 저자 teferi