아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Air Leak

면접 대비

시간 제한1초메모리 제한1024 MB

요약
이웃한 모듈 사이의 열린 문 목록과 손상된 모듈 좌표가 주어질 때, 열린 문을 따라 손상된 모듈에 도달할 수 있는 모든 모듈을 찾는다.
난이도

보통10점 중 5점

유형
그래프, BFS, 해시맵, 구현
정답자
아직 제출이 없습니다

문제

A space station is made up of cubic modules arranged in a 25×25×2525 \times 25 \times 25 grid. The position of each module in the grid is indicated by its X-, Y-, and Z-coordinates with integer values in the range 1…251 \ldots 25. Any pair of modules next to each other along the X-, Y-, or Z-axis is connected by a tunnel. Each tunnel has doors at both ends. If both doors are open, air may flow between the two modules.

One of the modules has been damaged and leaks air into the space. Air is also being lost from all those modules from which it can flow to the damaged module, either directly or via other modules. Find all the modules that are losing air. You may assume that the doors of the damages module still work correctly.

입력

The first line contains UU, the number of open doors in the station (1≤U≤10,0001 \le U \le 10\\,000). Each of the following UU lines describes one open door: the coordinates of the module and the direction of the door (the name of the axis and '+' for the direction of increasing values of the coordinate, or '-' for the decreasing direction). The last line contains the coordinates of the damaged module.

출력

Output the coordinates of all the modules that are losing air, each module on a separate line. Order the lines in ascending order first by the Z-, then by the Y-, and finally by the X-coordinates.

예제1

  1. 예제 1

    입력
    5
    2 1 1 X-
    1 1 1 X+
    1 1 1 Z+
    3 1 1 X-
    1 1 2 Z-
    1 1 1
    
    예상 출력
    1 1 1
    2 1 1
    1 1 2