Image Recognition | 프로그래밍의 벗 PivotOJ
PivotOJ

Image Recognition

시간 제한: 1000ms메모리 제한: 128MB출처: NEERC Northern Subregional 2009BOJ 3558
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

Irene works for Novel Efforts in Effective Recognition of Characters (NEERC). Her new project concerns image recognition using robots.

Since the approach is quite innovative, Irene starts with a very simple model first. She fixed dd images which are called digits 00 to d1d - 1. Each image is a w×hw \times h rectangle filled with white and black unit squares (call them pixels). All images are distinct (that is, each two images differ in at least one pixel).

The robot is placed in the upper left pixel of one of the images. It starts executing a program written in a specific programming language described below. The task of the robot is to recognize which of the dd images it was placed onto.

The programming language for the robot consists of the following commands:

  • 'U', 'D', 'L', 'R' --- movement commands. The robot moves one pixel up, down, left, or right respectively. If a movement command moves robot outside the image, the task is failed.
  • '(' subprogramw\langle subprogram_w \rangle ':' subprogramb\langle subprogram_b \rangle ')' --- conditional operator. The robot checks the color of the pixel underneath itself. If it is white then subprogramw\langle subprogram_w \rangle is executed, otherwise subprogramb\langle subprogram_b \rangle is executed.
  • '0', '1', ..., '9' --- recognized image commands. The robot must execute one of these commands when it knows which image it was placed onto. After such command, the program terminates.

Each movement command takes one time unit to execute. The execution of conditional operator and image recognized commands is instantaneous.

Irene is interested in the program that always works correctly. That is, if a robot is placed onto the image corresponding to the digit ii, then the execution of the program must end with the command 'i'.

Given the set of images, design a correct program for the robot, such that its execution time in the worst case is minimal.

입력

The first line contains three integers dd, hh, and ww (1d101 \le d \le 10; 1h,w101 \le h, w \le 10) --- the number of considered images, the height and the width of each image.

The rest if the input file contains dd descriptions of images. Each description consists of hh lines of length ww. All characters are either B or W, representing a black or a white pixel respectively.

Image descriptions are given in the order from 00 to d1d - 1. Descriptions are separated by an empty line.

출력

Return a correct program for the robot with minimal possible worst-case execution time. If there are multiple possible programs, output any of them.

All whitespace is ignored when parsing a program.

힌트

[이미지 1]

The robot has to distinguish between these three images in the example.

예제

예제 1

입력
3 5 4
WBBW
BWWB
BWWB
BWWB
WBBW

WWBW
WBBW
BWBW
WWBW
WWBW

WBBW
BWWB
WWBW
WBWW
BBBB
출력
D(1:D(2:0))
코드를 제출하려면 로그인하세요.