Logo
(追記) (追記ここまで)

18488번 - Um_nik’s Algorithm 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB17213119.016%

문제

Can you replicate my bachelor thesis in 5 hours?

I give you an undirected bipartite graph. Let K be the size of its maximum cardinality matching. Devise an algorithm to find a matching of size at least 0.95 · K.

If you want to get Accepted, I suggest you to optimize your code as good as you can.

입력

The first line contains three positive integers n1, n2 and m (1 ≤ n1, n2, m ≤ 2 · 106) — the number of vertices in the first part, the number of vertices in the second part and the number of edges in the graph, respectively.

The next m lines describe edges, one per line. Description of each edge is two integers u and v (1 ≤ u ≤ n1, 1 ≤ v ≤ n2) — the ids of vertices in first and second parts that are connected by the edge. There is no pair of edges connecting the same vertices.

출력

In the first line print one integer L — the size of the matching you found. The inequality 0.95 · K ≤ L should hold.

In the next L lines print the ids of the edges in your matching. Edges are numbered from 1 to m in the order they are given in input.

제한

예제 입력 1

3 2 4
1 1
2 1
3 1
3 2

예제 출력 1

2
1
4

예제 입력 2

20 20 20
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20

예제 출력 2

19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 8: Almost Algoritmic Contest A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /