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$ 英里。他要每段一英里裝一個,共 $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.