RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0096 파일 입출력

Bovine Ballet

Silver I 실버 I
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Farmer John's prize cow Bessie has signed up for an introductory ballet class, and FJ wants to build a rectangular stage large enough so that she can perform her entire dance without falling off the edges.

Bessie's dance takes place on a rectangular stage consisting of a grid of 1 x 1 square cells. Bessie's four feet are FR (front right), FL (front left), RR (rear right), RL (rear left). Her four feet start out in 4 adjacent cells forming a square, with Bessie facing north (FL and FR in the top row, RL and RR below them).

Bessie's dance follows a series of N instructions (1 <= N <= 1000), where each instruction tells her to either move one foot by one cell or to pivot 90 degrees clockwise.

A move instruction has 3 characters: the first two identify the foot (FR/FL/RR/RL), and the final character specifies the direction of movement (F = forward, B = back, R = right, L = left), relative to the direction Bessie is facing. For example, "FRF" means move the front right foot forward one cell.

A pivot instruction also has 3 characters: the first two specify the single foot Bessie keeps planted, around which she rotates 90 degrees clockwise, and the last character is "P". For example, "FRP" means pivot 90 degrees clockwise about the stationary front right foot.

Given the N instructions, please compute the minimum area of a rectangular stage necessary to contain her feet during the entire dance. If Bessie ever moves one foot onto the same cell as another foot, she trips; in that case output -1.

제약
입력 형식

Line 1: The integer N.

Lines 2..1+N: Each line contains one of the 3-character instructions in Bessie's dance.

출력 형식

The minimum area of a rectangular stage necessary to contain Bessie's feet during the entire dance, or -1 if Bessie trips.

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 ballet.in
출력을 쓸 파일 ballet.out
예제 1
입력
3
FRF
FRP
RLB
출력
16
설명

Output details: Bessie needs a 4 x 4 stage to complete her dance.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2012-2013 > US Open > Bronze

태그

평가 및 의견

Bovine Ballet

개요
출제자 난이도 Silver I 실버 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Bovine Ballet

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8