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

27095번 - Cowtography 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB398517.241%

문제

Farmer John wants to draw a map of his land, which is divided into rectangular fields. Each field is colored with a number (an integer in [1..1,000,000]). His goal is to design a map in which every adjacent pair of fields is colored differently.

Unfortunately, Farmer John's land is described in a rather unusual manner. His entire farm is a square, 1 kilometer on a side. The description of the layout of his farm is given by a sequence of lines, each of which contains one word or number per line.

The 1-by-1 kilometer square comprising the entire farm is described in the file as a series of one or more regions. A region can be specified by either:

  • A number giving the color of the region under consideration
  • The number "-1", indicating that the region under consideration is to be split evenly in half with a vertical line. Following the "-1" command will be descriptions of the left and then right halves, each described as a region.
  • The number "-2", indicating that the region under consideration is to be split evenly in half with a horizontal line. Following the "-2" command will be a description of the upper and then lower halves, each described as a region.

There are no more than 100 regions on Farmer John's property.

Your task is to determine the greatest number of adjacent regions colored with the same color.

입력

As above, a series of lines containing a number, the string 'hsplit', or the string 'vsplit'.

출력

A single line with an integer that tells the greatest number of adjacent fields have the same color.

제한

예제 입력 1

vsplit
5
hsplit
vsplit
37
6
5

예제 출력 1

2

힌트

The farm would resemble something like this:

+----------+------+-----+
| | | |
| | | |
| | | |
| | 37 | 6 |
| | | |
| | | |
| 5 +------+-----+
| | |
| | |
| | 5 |
| | |
| | |
| | |
+----------+------------+

출처

Olympiad > USA Computing Olympiad > 1999-2000 Season > USACO Spring 2000 Contest > Green 2번

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

출처

대학교 대회

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

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