A13814 | Blue and Red of Our Faculty!
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $N$ Checkpoints and $M$ undirected predetermined routes. Routes $i$ connects checkpoint $U_i$ and $V_i$ , for $(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 $Blue$ and $Red$ .
- $Blue$ will color every route in he walks on blue, $Red$ will color the route he walks on red. Both players start at checkpoint number $1$ . Initially, all routes are gray.
- Each phase, from their current checkpoint, $Blue$ and $Red$ select a different gray route and moves to the checkpoint on the other end of the route simultaneously.
- The game ends when $Blue$ or $Red$ 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 $U$ in a different color in the two configurations.
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 $Blue$ and $Red$ .
- $Blue$ will color every route in he walks on blue, $Red$ will color the route he walks on red. Both players start at checkpoint number $1$ . Initially, all routes are gray.
- Each phase, from their current checkpoint, $Blue$ and $Red$ select a different gray route and moves to the checkpoint on the other end of the route simultaneously.
- The game ends when $Blue$ or $Red$ 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 $U$ in a different color in the two configurations.
输入格式
The first line contains two integers $N$ and $M$ . $N$ $(2 \le N \le 2 \cdot 10^3)$ denotes the number of checkpoints, $M$ $(1 \le M \le 2 \cdot N)$ denotes the number of routes. It is guaranteed that every checkpoint except checkpoint $1$ has exactly two routes connecting it.
The next $M$ lines each contains two integers $U_i$ and $V_i$ $(1 \le U_i, V_i \le N, U_i \ne V_i)$ , which denotes the checkpoint that route $i$ connects.
It is guaranteed that for every pair of checkpoints, there exists a path connecting them directly or indirectly using the routes.
The next $M$ lines each contains two integers $U_i$ and $V_i$ $(1 \le U_i, V_i \le N, U_i \ne V_i)$ , which denotes the checkpoint that route $i$ connects.
It is guaranteed that for every pair of checkpoints, there exists a path connecting them directly or indirectly using the routes.
输出格式
Output a single integer which denotes the number of final configurations after each round of CPC modulo $10^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 $Blue$ took, and the red-colored numbers give the series of moves $Red$ took.
The blue-colored numbers give the series of moves $Blue$ took, and the red-colored numbers give the series of moves $Red$ took.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted