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

Measuring Traffic

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

의견: 0

설명

The highway adjacent to Farmer John's farm has recently seen a dramatic increase
in traffic, or at least so it seems to Farmer John. To be sure, he wants to
measure the traffic flow on the highway with a set of sensors, each capable of
measuring the rate of flow of traffic on a segment of road.

Unfortunately, while walking through the barn one day, Farmer John trips and
drops his box of sensors into a large vat of milk, after which they no longer
work as well. Instead of producing a single exact reading of traffic flow rate,
each sensor now outputs a range of possible values. For example, a sensor might
output the range \([7, 13]\), indicating that the rate of traffic flow on a
segment of road is no less than 7, and no greater than 13.

The highway runs for \(N\) miles next to the farm, and traffic on the highway only
flows in one direction, from mile 1 towards mile \(N\). Farmer John wants to
install \(N\) sensors -- one for each 1-mile segment of the highway. In some of
these segments, there are on-ramps that allow traffic to enter the highway; in each of
these cases, Farmer John will install his sensor on the on-ramp to measure
(approximately) the amount of incoming traffic. In some segments there are
off-ramps that allows traffic to exit the highway; in each of these cases, Farmer John will
install his sensor on the off-ramp. Each segment contains at most one ramp.
If there is no on-ramp or off-ramp in a segment of highway, Farmer John installs
a sensor on the main highway itself.

Given the readings from Farmer John's \(N\) sensors, please determine the most
specific possible ranges that describe the rate of traffic flow initially on
the highway prior to mile 1 and for traffic continuing on the highway past mile
\(N\). These ranges should be consistent with all \(N\) sensor readings.

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 describes a 1-mile segment of the road, in order from mile
\(1\) to mile \(N\). Each line contains a string that is either "on" (if there is
an on-ramp on this segment), "off" (if there is an off-ramp), or "none" (if
there is no ramp), followed by two integers in the range \(0 \ldots 1000\),
indicating the lower and upper endpoints of the sensor range from this segment.
If the segment contains a ramp, the sensor reading is from the ramp. Otherwise,
it is from the main highway. At least one of the highway segments will be
designated as "none".

출력 형식

The first line of output should contain two integers giving the most specific
range possible for the rate of traffic flow prior to mile 1. The second line of
output should contain two integers giving the most specific range possible for
the rate of traffic flow after mile \(N\). A valid solution is always guaranteed
to exist.

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 traffic.in
출력을 쓸 파일 traffic.out
예제 1
입력
4
on 1 1
none 10 14
none 11 15
off 2 3
출력
10 13
8 12
설명

In this example, the combination of readings from segments 2 and 3 tell us that
the flow rate through these segments is somewhere in the range \([11, 14]\), since
only this range is consistent with both the readings \([10,14]\) and \([11,15]\). In
mile 1, exactly 1 unit of flow enters on an on-ramp, so prior to mile 1, the
flow rate must be in the range \([10, 13]\). In mile 4, between 2 and 3 units
exits on an off-ramp, so the range of possible flow rates after this is
\([8,12]\).

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2018-2019 > February > Bronze

태그

평가 및 의견

Measuring Traffic

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

Log in to rate problems.

개별 의견

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

풀이 제출

Measuring Traffic

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