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.