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

10533번 - Ricochet Robots 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB88413154.386%

문제

A team of up-to four robots is going to deliver parts in a factory floor. The floor is organized as a rectangular grid where each robot ocupies a single square cell. Each robot is represented by an integer from 1 to 4 and can move in the four orthogonal directions (left, right, up, down). However, once set in motion, a robot will stop only when it detects a neighbouring obstacle (i.e. walls, the edges of the factory or other stationary robots). Robots do not move simultaneously, i.e. only a single robot moves at each time step.

The goal is to compute an efficient move sequence such that robot 1 reaches a designed target spot; this may require moving other robots out of the way or to use them as obstacles for “ricocheting” moves.

Consider the example given above, on the right, where the gray cells represent walls, X is the target location and 1 , 2 mark the initial positions of two robots. One optimal solution consists of the six moves described below.

Note that the move sequence must leave robot 1 at the target location and not simply pass through it (the target does not cause robots to stop — only walls, edges and other robots).

Given the description of the factory floor plan, the initial robot and target positions, compute the minimal total number of moves such that robot 1 reaches the target position.

입력

The first line contains the number of robots n, the width w and height h of the factory floor in cells, and an upper-bound limit l on the number of moves for searching solutions.

The remaining h lines of text represent rows of the factory floor with exactly w characteres each representing a cell position:

  • W a cell occupied by a wall;
  • X the (single) target cell;
  • 1,2,3,4 initial position of a robot;
  • ’.’ an empty cell.

출력

The output should be the minimal number of moves for robot 1 to reach the target location or NO SOLUTION if no solution with less than or equal the given upper-bound number of moves exists.

제한

  • 1 ≤ n ≤ 4
  • max(w, h) ≤ 10
  • w, h ≥ 1
  • 1 ≤ l ≤ 10

예제 입력 1

2 5 4 10
.2...
...W.
WWW..
.X.1.

예제 출력 1

6

예제 입력 2

1 5 4 10
.....
...W.
WWW..
.X.1.

예제 출력 2

NO SOLUTION

힌트

출처

ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2014 E번

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

출처

대학교 대회

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

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