QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#20925. 交通量の測定

Statistics

Farmer John は農場脇の高速道路の交通が最近急増したように感じます。確かめるため、道路区間の流量を測るセンサーを設置したいです。

しかし納屋を歩く途中でつまずき、センサーの箱を大きな牛乳の桶に落としました。以後、正確な値の代わりに可能な範囲しか出ません。$[7,13]$ なら流量は 7 以上 13 以下です。

道路は農場に沿って $N$ マイル続き、交通は第 1 マイルから第 $N$ マイルへ一方向です。各 1 マイル区間に一つ、計 $N$ センサーを置きます。入口ランプがある区間では入口で流入量を概測し、出口があれば出口で測ります。各区間にはランプが高々一つ。なければ本線で測ります。

$N$ の測定値から、第 1 マイル直前と第 $N$ マイル直後の流量の最も狭い可能範囲を求めてください。全測定値と整合する必要があります。

入力

最初は $N$($1\le N\le100$)。続く $N$ 行は第 $1$ から $N$ マイル順です。各行は on(入口)、off(出口)、none(なし)、続いて $0\ldots1000$ の二整数で測定範囲の下端と上端。ランプがあればそこで測り、なければ本線です。少なくとも一つ none があります。

出力

最初の行に第 1 マイル直前の最も狭い範囲の二整数、次に第 $N$ マイル直後の二整数。解の存在は保証されます。

入出力例

入力 1

4
on 1 1
none 10 14
none 11 15
off 2 3

出力 1

10 13
8 12

注記

区間 2、3 の $[10,14]$ と $[11,15]$ が共に許す範囲は $[11,14]$。第 1 マイルでちょうど 1 流入するので直前は $[10,13]$。第 4 マイルで 2〜3 流出するので直後は $[8,12]$。

問題作成:Brian Dean

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.