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

30270번 - Water Contamination 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB29131040.000%

문제

While the rain, mud, and their immediate effects (in particular, drownings) often cause the most initial damage, some of the long-term danger of hurricanes results from water contamination and diseases. The high levels of water can transport dangerous sewage or other contaminated substances from where they are typically kept away from people. Drinking contaminated water can be dangerous, of course. So it is important to keep contaminants contained, even when the water levels rise.

We will model this problem as follows. You will be given a list of places with contamination (such as sewage plants, garbage deposits, biohazard labs) and a list of places that must be protected (hospitals, city water processing plants), as well as connections between places; these connections are those that would be flooded and thus transport contaminants during/after the hurricane. Your goal is to find the smallest number of connections that need to be blocked (e.g., with large piles of sandbags) to protect all important places from all contaminants.

입력

The first line contains a number 1 ≤ K ≤ 100, which is the number of input data sets in the file. This is followed by K data sets of the following form:

The first line of the data set contains two integers n, c, with 1 ≤ n ≤ 500 the number of locations, and 0 ≤ c ≤ 5000 the number of connections.

This is followed by a line with n integers 0 ≤ ti ≤ 2, giving the type of location i. 0 means that it is neither contaminated nor important, 1 means that it is contaminated (but not important), and 2 means that it is important, i.e., must be protected (but is not contaminated). Next come c lines, each giving two integers 1 ≤ sj, tj ≤ n. This means that there is a connection between sj and tj along which contaminants could be spread (in either direction).

출력

For each data set, first output “Data Set x:” on a line by itself, where x is its number. Then, output the number of connections which must be blocked so that no important locations become contaminated.

Each data set should be followed by a blank line.

제한

예제 입력 1

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

예제 출력 1

Data Set 1:
5

힌트

출처

University > The USC Programming Contest > Fall 2023: Hurricane E번

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

출처

대학교 대회

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

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