P26648 [AtCoder] ISOLT
NOI
题目描述

Problem Description

Tetrominoes have 5 types as shown in the figure below: I, S, O, L, T.

A rabbit has some tetrominoes. The rabbit rotated and flipped them to arrange all of them without overlapping along a grid of $ H $ rows and $ W $ columns to create an art piece. The information of the covered cells by the tetrominoes is represented by a list of strings $ C $ as follows:

  • $ C_{i,j} $ is o if the cell at the $ i $-th row and $ j $-th column is covered.
  • $ C_{i,j} $ is . if the cell at the $ i $-th row and $ j $-th column is not covered.

Later, the rabbit tried to hang the art piece on the wall but accidentally broke it. The rabbit hurriedly gathered the scattered tetrominoes but could not find one.

Currently, the rabbit has $ I $ I tetrominoes, $ S $ S tetrominoes, and $ O $ O tetrominoes left. There are no L or T tetrominoes left. The rabbit also remembers the information $ C $ of the covered cells by the tetrominoes. The rabbit decided to infer the type of the lost tetromino from this information.

Input Format

The input is given from the standard input in the following format:

$ H $ $ W $ $ I $ $ S $ $ O $ $ C_{1,1} $$ C_{1,2} $$ ... $$ C_{1,W} $ $ C_{2,1} $$ C_{2,2} $$ ... $$ C_{2,W} $ $ : $ $ C_{H,1} $$ C_{H,2} $$ ... $$ C_{H,W} $

Output Format

Output the type of the tetromino that the rabbit lost, which can be one of I, S, O, L, T.

Sample Input and Output

Sample Input #1

4 5
1 1 1
o.ooo
ooooo
.o.oo
.oooo

Sample Output #1

L

Sample Input #2

5 9
1 4 2
.o.......
oooo.ooo.
oooo.oooo
ooo.ooooo
oooo.oooo

Sample Output #2

T

Sample Input #3

1 4
0 0 0
oooo

Sample Output #3

I

Sample Input #4

8 7
4 4 4
oooooo.
ooooooo
ooooooo
o.ooooo
ooooo.o
ooooooo
ooooooo
.oooooo

Sample Output #4

S

Notes/Hints

Constraints

  • $1 \leq H, W \leq 100$.
  • $0 \leq I, S, O$.
  • $ C_{i,j} $ is either o or ..
  • There exists at least one way to arrange the tetrominoes according to the problem statement.
  • The answer is uniquely determined.

Partial Points

  • If the answer is L or T for a dataset, 15 points are awarded.
  • If the answer is correct for a dataset without additional constraints, an additional 85 points are awarded.

Sample Explanation 1

The art piece created by the rabbit could be, for example, as shown in the figure below.

Sample Explanation 2

The art piece created by the rabbit could be, for example, as shown in the figure below.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 5 1 1 1 o.ooo ooooo .o.oo .oooo
样例输出
L