luogu#P10940. 舞动的夜晚

舞动的夜晚

Problem Description

Company LL and company HH held a social party.

At the party, NN employees from company LL and MM employees from company HH plan to have a ballroom dance.

Among these people, some employees from company LL and some employees from company HH know each other. There are TT such acquaintance pairs.

At the dance, each employee will try to choose one employee from the other company that they know as a partner, and each employee can dance at most once.

The more dances are completed, the more lively the party becomes.

To keep the party lively, they want to know which acquaintance pairs of employees, if they dance together, will reduce the maximum number of dances that the whole party can complete.

Input Format

The first line contains three integers N,M,TN, M, T.

The next TT lines each contain two integers x,yx, y, meaning employee xx of company LL and employee yy of company HH know each other.

Output Format

The first line contains an integer cntcnt, which is the number of acquaintance pairs such that, if that pair dances, the maximum number of dances the whole party can complete will decrease.

The second line contains cntcnt integers, output in increasing order, which are the indices of such acquaintance pairs (i.e., the position of that acquaintance pair in the input).

If cnt=0cnt=0, output an empty line.

3 3 6
1 1
2 1
2 2
3 1
3 2
3 3
3
2 4 5

Hint

Constraints: 1N,M100001 \le N, M \le 10000, 1T1000001 \le T \le 100000, 1xN1 \le x \le N, 1yM1 \le y \le M.

Translated by ChatGPT 5