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

15166번 - Loading Cargo 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB89231931.667%

문제

We need to ship N capsules containing different potentially hazardous chemicals using an aircraft. The aircraft has one cargo compartment on the left with free space for L capsules and one cargo compartment on the right with free space for R capsules. According to the safety regulations, some capsules conflict with each other and cannot be loaded into the same cargo compartment (in case there is leakage and reaction). Given this information, your job is to determine whether all the capsules can be loaded into the aircraft.

입력

The input starts with a line containing four integers L, R, N and C, where L (0 ≤ L ≤ 2 000) is the capacity of the left cargo compartment, R (0 ≤ R ≤ 2 000) is the capacity of the right cargo compartment, N (0 ≤ N ≤ 2 000) is the number of capsules and C (0 ≤ C ≤ 200 000) is the number of conflicts.

The next C lines describe the conflicts. Each of these lines contain two integers X (0 ≤ X ≤ N − 1) and Y (0 ≤ Y ≤ N − 1 and X ≠ Y ) representing a pair of capsules that conflict with each other. Each pair of capsules that conflict only appear once in the input. The capsules are numbered from 0 to N − 1.

출력

Display Yes if all the capsules can be loaded into the aircraft and display No otherwise.

제한

예제 입력 1

0 0 0 0

예제 출력 1

Yes

예제 입력 2

3 3 3 3
0 1
1 2
2 0

예제 출력 2

No

예제 입력 3

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

예제 출력 3

Yes

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > ACM ICPC South Pacific Divisionals > 2016 South Pacific Divisional Contest L번

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

출처

대학교 대회

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

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