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

31483번 - Supporting everyone 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.25 초 1024 MB68636192.424%

문제

Alice is attending a sport event with many national teams and one thing is important to her: supporting every country.

There are $N$ countries represented and she has two ways to support a country: either have the flag drawn on her or have a pin with the name of the country. Alice has a list containing, for each country, the colours needed to make its flag. A total of $M$ colours that may appear across all flags and, in Alice’s list, each colour is conveniently represented as an integer between 1ドル$ and $M$.

Each crayon and pin cost 1ドル,ドル but her budget is tight. . . Can you help her find the minimum she can spend to support everyone?

입력

The first line contains the two space-separated numbers $N$ and $M$. Then follow 2ドルN$ lines, grouped in pairs; the $(2i - 1)$th and 2ドルi$th lines represent the $i$th country. More precisely, the $(2i - 1)$th line contains a single integer $k_i$: the number of colours in the flag of the $i$th country. Then, the 2ドルi$th line contains $k_i$ space-separated numbers $c_{i,1}, c_{i,2}, \dots , c_{i,k_i}$; these are the colours in the flag of the $i$th country.

출력

The output should contain a single line, consisting of a single number: the minimum amount Alice can spend on crayons and pins to represent every country.

제한

  • 1ドル \le N \le 1,円 000$
  • 1ドル \le M \le 100$
  • 1ドル \le k_i \le M$ for all $i \le N$
  • 1ドル \le c_{i,j} \le M$ for all $i \le N$ and $j \le k_i$
  • for all $i \le N,ドル the $M$ colour numbers $c_{i,j}$ are pairwise distinct.

예제 입력 1

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

예제 출력 1

5

The three first countries could be France, the Netherlands, and the Czech Republic, all represented by blue (1), white (4), and red (5). The three next countries could be Italy, Hungary, and Bulgaria, with green (3), white (4) and red (5). The last one could be Germany, with black (2), red (5), and yellow (6). The minimum cost is 5: we buy four (blue, green, white, and red) crayons and one pin (for Germany).

예제 입력 2

8 12
2
7 9
12
1 2 3 4 5 6 7 8 9 10 11 12
2
7 9
2
7 9
3
3 4 11
2
7 9
2
7 9
2
7 9

예제 출력 2

4

We can buy two crayons for the colours 7 and 11 and buy two pins for a total cost of 4. All six countries with flag colours 7 (red) and 11 (white) could be Canada, Indonesia, Japan, Malta, Monaco, and Poland. The flag of Belize has 12 colours, including red and white, and the fifth country could be Botswana.

힌트

출처

ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2023-2024 B번

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

출처

대학교 대회

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

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