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

13088번 - Cube Dividing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB8013844.444%

문제

Pablo Cubarson is a well-known cubism artist. He is producing a new piece of work using a cuboid which consists of A×B×C unit cubes. He plans to make a beautiful shape by removing N units cubes from the cuboid. When he is about to begin the work, he has noticed that by the removal the cuboid may be divided into several parts disconnected to each other. It is against his aesthetics to divide a cuboid. So he wants to know how many parts are created in his plan.

Your task is to calculate the number of connected components in the cuboid after removing the N cubes. Two cubes are connected if they share one face.

입력

The input consists of a single test case. The test case is formatted as follows:

A B C N
X1 Y1 Z1
...
XN YN ZN

The first line contains four integers A, B, C and N. A, B and C (1 ≤ A, B, C ≤ 106) denote the size of the cuboid --- the cuboid has an A unit width from left to right and a B unit height from bottom to top, and a C unit depth from front to back. N (0 ≤ N ≤ 20,000, N ≤ A×B×C−1) denotes the number of the cubes removed in the Cubarson’s plan. Each of the following N lines contains three integers Xi (0 ≤ Xi ≤ A−1), Yi (0 ≤ Yi ≤ B−1) and Zi (0 ≤ Zi ≤ C−1). They denote that the cube located at the Xi-th position from the left, the Yi-th from the bottom and the Zi-th from the front will be removed in the plan. You may assume the given positions are distinct.

출력

Print the number of the connected components in the cuboid after removing the specified cubes.

제한

예제 입력 1

2 2 2 4
0 0 0
1 1 0
1 0 1
0 1 1

예제 출력 1

4

예제 입력 2

3 3 3 1
1 1 1

예제 출력 2

1

예제 입력 3

1 1 3 2
0 0 0
0 0 2

예제 출력 3

1

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Practice Contest for ICPC Asia Regional > JAG Practice Contest for ACM-ICPC Asia Regional 2015 G번

  • 문제의 오타를 찾은 사람: rhrnald
(追記) (追記ここまで)

출처

대학교 대회

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

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