QOJ.ac

QOJ

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

#77. נהיגה

الإحصائيات

ישנן $N$ ערים ו־$M$ דרכים דו־כיווניות. הערים ממוספרות מ־$1$ עד $N$, והדרכים ממוספרות מ־$1$ עד $M$. הדרך $i$ מחברת בין הערים $A_i$ ו־$B_i$, ואורכה הוא $2^i$. מובטח שאפשר להגיע מכל עיר לכל עיר באמצעות הדרכים האלה.

Snuke רוצה לצאת לנסיעה. הוא רוצה להתחיל בעיר $1$, לעבור בכל דרך לפחות פעם אחת ולחזור לעיר $1$. חשבו את האורך הקטן ביותר האפשרי של המסלול שלו, מודולו $10^9+7$.

קלט

$$ \begin{gathered} N\ M\\ A_1\ B_1\\ \vdots\\ A_M\ B_M \end{gathered} $$

  • $2 \le N \le 400000$
  • $1 \le M \le 500000$
  • $1 \le A_i,B_i \le N$
  • $A_i \ne B_i$
  • אפשר להגיע מכל עיר לכל עיר באמצעות הדרכים.
  • אין שתי דרכים שמחברות בין אותו זוג ערים.

פלט

הדפיסו את האורך הקטן ביותר האפשרי של המסלול של Snuke, מודולו $10^9+7$.

דוגמאות

קלט 1

4 5
1 2
3 4
2 3
1 3
2 4

פלט 1

70

קלט 2

6 10
4 6
4 5
3 6
5 2
3 2
1 2
3 4
6 1
2 4
1 3

פלט 2

2132

הערה

problem_77_c4a852b77bf0c07183d959c2e4f292c6.png

למשל, בדוגמה $1$ אחד המסלולים המיטביים הוא $1\to2\to3\to4\to2\to3\to1$.

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.