QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 2048 MB Total points: 100

#265. 正则二分图匹配

統計

题目描述

这是一道模板题。

给定一个正则二分图 $G=(X,Y,E)$,其中 $|X|=|Y|=n$ 且每个点的度数均为 $d$,请你求出一个其完美匹配。

输入格式

第一行输入两个正整数 $n,d$,意义如题目描述所示。

接下来 $n$ 行每行输入 $d$ 个正整数,其中第 $i+1$ 行若输入一个正整数 $j$ 则表示 $x_i$ 与 $y_j$ 连一条边。图中可能有重边

保证给出的图是 $d$-正则图。

输出格式

输出一行 $n$ 个整数,是一个 $1,\dots,n$ 的排列,表示一个完美匹配,设 $p_i=j$,表示 $x_i$ 向 $y_j$ 连边为匹配中的一条。

样例数据

样例输入

4 2
3 4
1 3
2 2
1 4

样例输出

4 3 2 1

子任务

对于 $30\%$ 的数据,保证 $n\times d\le 2\times 10^5$。

对于另外 $30\%$ 的数据,保证 $d$ 是 $2$ 的整次幂。

对于 $100\%$ 的数据,保证 $n\times d\le 2\times 10^6$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.