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

33743번 - Candidate Elimination 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 2048 MB31133.333%

문제

James has been learning how to solve sudoku puzzles recently. He had recently learned about a concept called "Naked Pairs". A pair of cells $P$ is called a Naked Pair when it satisfies the following conditions.

  • The two cells lie in the same group. In sudoku, a group is a set of $n$ cells that must contain all integers from 1ドル$ to $n$.
  • Both cells contain a subset of the same set of candidates $S,ドル where $|S|=2$.

Given a naked pair, one can remove the candidates in $S$ from all other cells in the group, since you know that in a valid sudoku each candidate in $S$ must appear in one of the two cells.

While learning more about it, James realized that the concept of a "Naked Subset" can generalize the naked pairs. A set of cells $Q$ with $k$ cells is called a Naked Subset when it satisfies the following conditions.

  • The $k$ cells lie in the same group.
  • All cells in $Q$ contain a subset of the same set of candidates $S',ドル where $|S'|=k$.

Given a naked subset, one can remove the candidates in $S'$ from all other cells in the group, since you know that in a valid sudoku each candidate in $S'$ must appear in one of the $k$ cells.

James has been whining about how hard it is to find naked subsets in very big sudoku puzzles. Given a group, your job is to find every candidate that can be eliminated using exactly one naked subset.

입력

The first line consists of one integer $n,ドル the size of one group. (1ドル \le n \le 10^5$)

The following $n$ lines represent cells that belong to the group. The $i$-th line consists of one integer $S_i,ドル followed by $S_i$ distinct integers. The $S_i$ integers represent the candidates possible on the $i$-th cell.

It is guaranteed that the sum of $S_i$ is at most 5ドル\cdot 10^5$.

Additionally, it is guaranteed that there is a valid assignment to all cells in the group. In other words, there exists at least one way to choose one candidate per cell, such that all integers chosen are distinct.

출력

Output $n$ lines. The $i$-th line must consist of the candidates that can be removed from the $i$-th cell in increasing order, with the format being same as the input format.

제한

예제 입력 1

9
3 2 4 5
2 2 5
2 2 4
4 4 5 7 8
2 5 7
1 3
1 6
1 9
4 1 2 7 8

예제 출력 1

0
0
0
3 4 5 7
1 5
0
0
0
3 2 7 8

노트

In the first sample, the cells in the group belong to the box with green digits. The removals are done using the following naked subsets.

  • Cells 1,2,3ドル$ have candidates $\{2,4,5\},ドル so you can remove $\{4,5\}$ from cell 4ドル,ドル $\{5\}$ from cell 5ドル$ and $\{2\}$ from cell 9ドル$.
  • Cells 1,2,3,5ドル$ have candidates $\{2,4,5,7\},ドル so you can remove $\{7\}$ from cells 4ドル$ and 9ドル$.
  • Cells 1,2,3,4,5ドル$ have candidates $\{2,4,5,7,8\},ドル so you can remove $\{8\}$ from cell 9ドル$.

The sudoku board corresponding to the sample. Generated using HoDoKu, an open source sudoku solver.

출처

Camp > Osijek Competitive Programming Camp > Summer 2024 > Day 5: OCPC Potluck Contest 2 C번

  • 문제를 만든 사람: tfg
(追記) (追記ここまで)

출처

대학교 대회

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

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