QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#22426. Kuhrettung

الإحصائيات

Bessie steckt in einem Dreieckslabyrinth mit $N$ Reihen, $1 \le N \le 1,000,000$. Unten sind drei Reihen gezeigt.

download.php?type=attachments&id=2948&r=0

Reihe $i$ hat $2*i-1$ Dreiecke, von links $(i,1)$, $(i,2)$ usw.

Sie kann zu Dreiecken mit gemeinsamer Kante gehen, oft drei. Von $(3,3)$ nach $(3,2)$, $(3,4)$, $(4,4)$. Ein Schritt dauert eine Minute.

download.php?type=attachments&id=2948&r=1

FJ erfährt ihre Lage und verfolgt ihr iPhone: Der Weg zum Ausgang beginnt bei ($Si,Sj$). Seine Liebe ist grenzenlos, er will sie schnellstmöglich zurück.

Es gibt $M$ verteilte Ausgänge, $1 \le M \le 10,000$, jeder ermöglicht Flucht. Nach Betreten eines Ausgangsdreiecks braucht sie noch eine Minute nach draußen.

Finde die minimale Zeit $T$ Minuten und den optimalen Ausgang $(OUTi, OUTj)$. Bei gleichen $T$ kleinste Reihe, bei gleicher Reihe kleinere Spalte.

Eingabe

  • Zeile $1$: ganze Zahlen $N$, $M$ durch Leerzeichen.

  • Zeile $2$: ganze Zahlen $Si$, $Sj$ durch Leerzeichen.

  • Zeilen $3..M+2$: Zeile $i+2$, zwei ganze Zahlen durch Leerzeichen $Ei$, $Ej$, Dreieck des Ausgangs $i$.

Ausgabe

  • Zeile $1$: ganze Zahlen $OUTi$, $OUTj$ durch Leerzeichen.

  • Zeile $2$: eine ganze Zahl $T$.

Beispiele

Eingabe 1

4 2
2 1
3 5
4 4

Ausgabe 1

4 4
4

Aufgabenautor: Ye Wang, 2009

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.