| 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()