목차

Exits in Excess

ps
링크acmicpc.net/…
출처BOJ
문제 번호17546
문제명Exits in Excess
레벨골드 3
분류

DAG

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

풀이

코드

"""Solution code for "BOJ 17546. Exits in Excess".

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

Tags: [ad hoc]
"""

import sys


def main():
    _n, m = [int(x) for x in sys.stdin.readline().split()]
    inc_order_edges, dec_order_edges = [], []
    for i in range(1, m + 1):
        u, v = [int(x) for x in sys.stdin.readline().split()]
        if u < v:
            inc_order_edges.append(i)
        else:
            dec_order_edges.append(i)

    answer = min((inc_order_edges, dec_order_edges), key=len)
    print(len(answer))
    print(*answer, sep='\n')


if __name__ == '__main__':
    main()