CF1425B.Blue and Red of Our Faculty!

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

It's our faculty's 34th anniversary! To celebrate this great event, the Faculty of Computer Science, University of Indonesia (Fasilkom), held CPC - Coloring Pavements Competition. The gist of CPC is two players color the predetermined routes of Fasilkom in Blue and Red. There are NN Checkpoints and MM undirected predetermined routes. Routes ii connects checkpoint UiU_i and ViV_i, for (1≤i≤M)(1 \le i \le M). It is guaranteed that any pair of checkpoints are connected by using one or more routes.

The rules of CPC is as follows:

  • Two players play in each round. One player plays as blue, the other plays as red. For simplicity, let's call these players BlueBlue and RedRed.
  • BlueBlue will color every route in he walks on blue, RedRed will color the route he walks on red. Both players start at checkpoint number 11. Initially, all routes are gray.
  • Each phase, from their current checkpoint, BlueBlue and RedRed select a different gray route and moves to the checkpoint on the other end of the route simultaneously.
  • The game ends when BlueBlue or RedRed can no longer move. That is, there is no two distinct gray routes they can choose to continue moving.

Chaneka is interested in participating. However, she does not want to waste much energy. So, She is only interested in the number of final configurations of the routes after each round. Turns out, counting this is also exhausting, so Chaneka asks you to figure this out!

Two final configurations are considered different if there is a route UU in a different color in the two configurations.

这是我们学院成立34周年纪念日!为庆祝这一盛事,印度尼西亚大学计算机科学学院(Fasilkom)举办了“CPC——路面涂色竞赛”(Coloring Pavements Competition)。CPC 的核心规则是:两名选手轮流将 Fasilkom 校园内预先设定的路径分别涂成蓝色与红色。共有 NN 个检查点(Checkpoints)和 MM 条无向的预设路径。第 ii 条路径连接检查点 UiU_i 和 ViV_i(其中 1≤i≤M1 \le i \le M)。保证任意两个检查点之间均存在一条或多条路径相连(即图连通)。

CPC 的具体规则如下:

  • 每轮由两名玩家参与:一名扮演蓝色方,另一名扮演红色方。为叙述简便,我们称他们为 BlueBlue 和 RedRed。
  • BlueBlue 将其走过的每条路径涂成蓝色,RedRed 将其走过的每条路径涂成红色。双方均从编号为 11 的检查点出发;初始时,所有路径均为灰色。
  • 在每一阶段中,双方从当前所处的检查点出发,各自选择一条不同的灰色路径,并同时沿该路径移动至该路径另一端的检查点。
  • 游戏在 BlueBlue 或 RedRed 无法继续行动时结束。即:不存在两条互不相同的灰色路径可供双方同时选择以继续移动。

Chaneka 对参赛很感兴趣,但她不愿耗费过多精力。因此,她只关心每轮游戏结束后路径颜色配置的总数。然而,手动计数同样十分费力,于是 Chaneka 请求你来解决这个问题!

若两种最终配置中存在某条路径 UU 的颜色不同,则认为这两种配置互不相同。

输入格式

The first line contains two integers NN and MM. NN (2≤N≤2⋅103)(2 \le N \le 2 \cdot 10^3) denotes the number of checkpoints, MM (1≤M≤2⋅N)(1 \le M \le 2 \cdot N) denotes the number of routes. It is guaranteed that every checkpoint except checkpoint 11 has exactly two routes connecting it.

The next MM lines each contains two integers UiU_i and ViV_i (1≤Ui,Vi≤N,Ui≠Vi)(1 \le U_i, V_i \le N, U_i \ne V_i), which denotes the checkpoint that route ii connects.

It is guaranteed that for every pair of checkpoints, there exists a path connecting them directly or indirectly using the routes.

第一行包含两个整数 NN 和 MM。其中 NN (2≤N≤2⋅103)(2 \le N \le 2 \cdot 10^3) 表示检查点的数量,MM (1≤M≤2⋅N)(1 \le M \le 2 \cdot N) 表示路径的数量。保证除检查点 11 外,其余每个检查点恰好与两条路径相连。

接下来的 MM 行,每行包含两个整数 UiU_i 和 ViV_i (1≤Ui,Vi≤N,Ui≠Vi)(1 \le U_i, V_i \le N, U_i \ne V_i),表示第 ii 条路径所连接的两个检查点。

保证任意两个检查点之间均存在一条(直接或间接)路径通过这些路径相连。

输出格式

Output a single integer which denotes the number of final configurations after each round of CPC modulo 109+710^9 + 7

输出一个整数,表示每轮 CPC 后的最终配置数量对 109+710^9 + 7 取模的结果。

输入输出样例

  • 输入#1

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

    输出#1

    8

说明/提示

Every possible final configuration for the example is listed below:

The blue-colored numbers give the series of moves BlueBlue took, and the red-colored numbers give the series of moves RedRed took.

以下列出了该示例中所有可能的最终局面:

蓝色数字表示 BlueBlue 所执行的操作序列,红色数字表示 RedRed 所执行的操作序列。

输入解题思路,AI测评打分。不知道怎么写?

首页