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

28178번 - Greedy Bipartite Matching 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 1024 MB279646.154%

문제

Consider a bipartite weighted graph with 2ドル n$ vertices: $n$ in the left part and $n$ in the right part. The vertices in each part are numbered from 1ドル$ to $n$. A matching is called greedy if it has the maximal number of edges of weight 1ドル$ among all matchings, the maximal number of edges of weight 2ドル$ among all matchings that maximize the number of edges of weight 1ドル,ドル etc.

Your task is to find the size (number of edges) of greedy matching in a dynamically growing graph.

입력

The first line of the input contains two non-negative integers $n$ and $q$ ($n \leq 10^5,ドル $q \leq 10^3$): the number of vertices in each part and the number of different weights of the edges.

Then, the input consists of $q$ blocks. The $i$-th block starts with a non-negative integer $m_i$: the number of edges of weight $i$. Each of the next $m_i$ lines contains two integers $x$ and $y$ (1ドル \leq x, y \leq n$), which add an edge between vertex $x$ of the left part and vertex $y$ of the right part. It is guaranteed that $\sum_i m_i \leq 2 \cdot 10^5$.

Note that there may be multiple edges between two vertices.

출력

You have to output $q$ integers on a single line: answers for the problem for weights at most 1ドル,ドル weights at most 2ドル,ドル \ldots, weights at most $q$.

제한

예제 입력 1

3 4
2
1 1
1 2
2
1 1
2 2
2
1 3
3 2
1
3 3

예제 출력 1

1 2 2 3

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2023 > Day 5: LOUD Enough Contest 2 A번

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

출처

대학교 대회

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

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