#P8867. [NOIP2022] 建造军营
[NOIP2022] 建造军营
Description
Countries A and B are at war, and country A plans to build some military camps on its own territory.
Country A’s territory consists of cities, connected by bidirectional roads, such that any two cities are directly or indirectly reachable through the roads. Country A will choose one or more cities (at least one) and build exactly one military camp in each chosen city.
It is well known that communication between camps is crucial. However, country A has received intelligence that country B will soon attack one of A’s roads, but the exact target is unknown. If B’s attack succeeds, that road will be cut, which may cause some two camps in A to be unable to reach each other, something A is keen to avoid. Therefore, A decides to station troops to guard some roads (it could be one or more, or possibly none). Country A is confident that any guarded road can withstand B’s attack and will not be cut.
Country A wants to design a plan for building camps and guarding roads such that, no matter which road in A is attacked by B, it will not cause any two camps to be unable to reach each other. Please help country A calculate how many possible plans there are for building camps and guarding roads. Since the number of plans may be large, output the value modulo . Two plans are considered different if and only if there exists at least one city that has a camp in one plan but not in the other, or there exists at least one road that is guarded in one plan but not in the other.
Input Format
The first line contains two positive integers , denoting the number of cities and the number of bidirectional roads, respectively.
The next lines each contain two positive integers , describing a bidirectional road connecting and . There are no multiple edges or self-loops.
Output Format
Output one line containing an integer, the number of valid plans for building camps and guarding roads, modulo .
2 1
1 2
5
4 4
1 2
2 3
3 1
1 4
184
见附加文件里的 barrack/barrack3.in
见附加文件里的 barrack/barrack3.ans
见附加文件里的 barrack/barrack4.in
见附加文件里的 barrack/barrack4.ans
Hint
Sample 1 Explanation
In the sample, country A has two cities, with road connecting them.
All possible plans are as follows:
- Build a camp in city , do not guard the road.
- Build a camp in city , guard the road.
- Build a camp in city , do not guard the road.
- Build a camp in city , guard the road.
- Build camps in cities , guard the road.
Constraints
For all testdata, it is guaranteed that , , , .
| Test point ID | Special condition | ||
|---|---|---|---|
| None | |||
| ^ | |||
| Special property | |||
| ^ | |||
| None | |||
Special property : guarantee and the -th road connects city and .
Translated by ChatGPT 5
京公网安备 11011102002149号