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

Mowing the Field

Bronze II 브론즈 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Farmer John is quite reliable in all aspects of managing his farm, except one:
he is terrible at mowing the grass in a timely or logical fashion.

The farm is a large 2D grid of square unit cells. FJ starts in one of these
cells at time \(t = 0\), mowing the grass in this cell so that it is initially the
only cell in which the grass is cut. FJ's remaining mowing pattern is
described by a sequence of \(N\) statements. For example, if the first statement
is "W 10", then for times \(t = 1\) through \(t = 10\) (i.e., the next 10 units of
time), FJ will step one cell to his west, mowing the grass along the way.
After completing this sequence of steps, he will end up 10 cells to his west at
time \(t = 10\), having mowed the grass in every cell along the way.

So slow is FJ's progress that some of the grass he mows might grow back before
he is finished with all his mowing. Any section of grass that is cut at time \(t\)
will reappear at time \(t + x\).

FJ's mowing pattern might have him re-visit the same cell multiple times, but he
remarks that he never encounters a cell in which the grass is already cut. That
is, every time he visits a cell, his most recent visit to that same cell must
have been at least \(x\) units of time earlier, in order for the grass to have
grown back.

Please determine the maximum possible value of \(x\) so that FJ's observation
remains valid.

Problem credits: Brian Dean

제약

Problem credits: Brian Dean

입력 형식

The first line of input contains \(N\) (\(1 \leq N \leq 100\)). Each of the
remaining \(N\) lines contains a single statement and is of the form 'D S', where
D is a character describing a direction (N=north, E=east, S=south, W=west) and S
is the number of steps taken in that direction (\(1 \leq S \leq 10\)).

출력 형식

Please determine the maximum value of \(x\) such that FJ never steps on a cell
with cut grass. If FJ never visits any cell more than once, please
output -1.

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 mowing.in
출력을 쓸 파일 mowing.out
예제 1
입력
6
N 10
E 2
S 3
W 4
S 5
E 8
출력
10
설명

In this example, FJ steps on a cell at time 17 that he stepped on earlier at
time 7; therefore, \(x\) must be at most 10 or else the grass from his first visit
would not yet have grown back. He also steps on a cell at time 26 that he also
visited at time 2; hence \(x\) must also be at most 24. Since the first of these
two constraints is tighter, we see that \(x\) can be at most 10.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2015-2016 > January > Bronze

태그

평가 및 의견

Mowing the Field

개요
출제자 난이도 Bronze II 브론즈 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Mowing the Field

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