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\ldots 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

Note

קטעים 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.