A7873 | Road Problem
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The Berland capital (as you very well know) contains $n$ junctions, some pairs of which are connected by two-way roads. Unfortunately, the number of traffic jams in the capital has increased dramatically, that's why it was decided to build several new roads. Every road should connect two junctions.
The city administration noticed that in the cities of all the developed countries between any two roads one can drive along at least two paths so that the paths don't share any roads (but they may share the same junction). The administration decided to add the minimal number of roads so that this rules was fulfilled in the Berland capital as well. In the city road network should exist no more than one road between every pair of junctions before or after the reform.
The city administration noticed that in the cities of all the developed countries between any two roads one can drive along at least two paths so that the paths don't share any roads (but they may share the same junction). The administration decided to add the minimal number of roads so that this rules was fulfilled in the Berland capital as well. In the city road network should exist no more than one road between every pair of junctions before or after the reform.
输入格式
The first input line contains a pair of integers $n$ , $m$ ( $2<=n<=900,1<=m<=100000$ ), where $n$ is the number of junctions and $m$ is the number of roads. Each of the following $m$ lines contains a description of a road that is given by the numbers of the connected junctions $a_{i},b_{i}$ ( $1<=a_{i},b_{i}<=n,a_{i}≠b_{i}$ ). The junctions are numbered from 1 to $n$ . It is possible to reach any junction of the city from any other one moving along roads.
输出格式
On the first line print $t$ — the number of added roads. Then on $t$ lines print the descriptions of the added roads in the format of the input data. You can use any order of printing the roads themselves as well as the junctions linked by every road. If there are several solutions to that problem, print any of them.
If the capital doesn't need the reform, print the single number 0.
If there's no solution, print the single number -1.
If the capital doesn't need the reform, print the single number 0.
If there's no solution, print the single number -1.
输入输出样例
输入 #1
4 3 1 2 2 3 3 4
输出 #1
1 1 4
输入 #2
4 4 1 2 2 3 2 4 3 4
输出 #2
1 1 3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted