목차

Just Half is Enough

ps
링크acmicpc.net/…
출처BOJ
문제 번호32925
문제명Just Half is Enough
레벨골드 4
분류

ad hoc

시간복잡도O(E)
인풋사이즈E<=2*10^5
사용한 언어Python 3.13
제출기록37048KB / 212ms
최고기록212ms
해결날짜2026/02/14

풀이

코드

"""Solution code for "BOJ 32925. Just Half is Enough".

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

Tags: [ad hoc]
"""

import sys
from teflib import psutils


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

    inc_order_count = 0
    for _ in range(m):
        u, v = [int(x) - 1 for x in sys.stdin.readline().split()]
        if u < v:
            inc_order_count += 1

    if inc_order_count >= (m + 1) // 2:
        print(*range(1, n + 1))
    else:
        print(*reversed(range(1, n + 1)))


if __name__ == '__main__':
    main()