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

21082번 - Assignment Problem 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 256 MB22141463.636%

문제

There are $m$ open positions in our company and $n \ge m$ candidates for these positions. We want to hire the best candidates, obviously. We can't hire the same candidate for two or more different positions, so we have to hire exactly $m$ candidates. Let's call the way to choose different candidates for each position an assignment. Two assignments are different if there exists a position for which we hire different candidates in these assignments.

There is a matrix $A$ of profits: $A_{ij} \ge 0$ denotes what profit we will gain from hiring $j$-th candidate for $i$-th position. We want to maximize the sum of profits we will gain from all hires. An assignment is optimal if it maximizes the sum of profits.

It would be easy to choose the best candidates given the matrix $A$. Unfortunately, HR world is not so simple, and they can't provide the matrix $A$ for you. Even after interviewing all the candidates we can only compare how two candidates will behave in the same position. More precisely, we know $m$ permutations $P_{i}$ of length $n$. For all 1ドル \le i \le m,ドル 1ドル \le x < y \le n$: $A_{i P_{ix}} > A_{i P_{iy}}$. In human words, for each position we know the ranking of all candidates.

A candidate is promising if and only if there exists a matrix $A$ which is consistent with all the given rankings, such that for this matrix there is only one optimal assignment and this particular candidate is hired.

You are to find all promising candidates so that we can conduct more thorough tests with them.

입력

The first line contains two integers $n$ and $m$ (1ドル \le m \le 11,ドル $m \le n \le 1000$) --- the number of candidates and the number of positions.

Next $m$ lines contain rankings for each position. The $i$-th line contains a permutation $P_{i1}, P_{i2}, \ldots, P_{in}$ of numbers from 1ドル$ to $n$.

출력

In the first line print the number of promising candidates, in the second line print indices of promising candidates in increasing order.

제한

예제 입력 1

4 2
1 2 4 3
1 3 4 2

예제 출력 1

3
1 2 3

예제 입력 2

4 2
1 4 3 2
2 3 4 1

예제 출력 2

2
1 2

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 5: Almost Retired Dandelion Contest, ICPC Camp Contest 2 A번

Contest > Open Cup > 2020/2021 Season > Stage 11: Grand Prix of Nizhny Novgorod A번

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

출처

대학교 대회

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

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