목차

Contact

ps
링크boj.kr/…
출처BOJ
문제 번호1013
문제명Contact
레벨골드 5
분류

정규 표현식

시간복잡도O(T*regex(n))
인풋사이즈T<=?, n<=200
사용한 언어Python 3.13
제출기록37004KB / 112ms
최고기록32ms
해결날짜2025/03/07

풀이

코드

"""Solution code for "BOJ 1013. Contact".

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

Tags: [regex]
"""

import re
import sys
from teflib import psutils

PATTERN = re.compile(r'^(100+1+|01)+$')


@psutils.run_n_times
def main():
    s = sys.stdin.readline().rstrip()
    print('YES' if PATTERN.match(s) else 'NO')


if __name__ == '__main__':
    main()