QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 512 MB Total points: 100

#77. Поїздка автомобілем

Statistics

Є $N$ міст і $M$ двосторонніх доріг. Міста пронумеровано від $1$ до $N$, а дороги — від $1$ до $M$. Дорога $i$ з'єднує міста $A_i$ та $B_i$, а її довжина дорівнює $2^i$. Гарантується, що цими дорогами можна дістатися з будь-якого міста до будь-якого іншого.

Snuke хоче покататися на автомобілі. Він хоче почати в місті $1$, проїхати кожною дорогою принаймні один раз і повернутися до міста $1$. Обчисліть найменшу можливу довжину його маршруту за модулем $10^9+7$.

Вхідні дані

Формат вхідних даних:

$$ \begin{gathered} N\quad M \\ A_1\quad B_1 \\ \vdots \\ A_M\quad 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_84faca0aeb8cb2b57b795642c67b82c7.png

Наприклад, у першому прикладі один з оптимальних маршрутів — $1 \to 2 \to 3 \to 4 \to 2 \to 3 \to 1$.

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.