A9788 | Data Center Drama
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The project of a data center of a Big Software Company consists of $n$ computers connected by $m$ cables. Simply speaking, each computer can be considered as a box with multiple cables going out of the box. Very Important Information is transmitted along each cable in one of the two directions. As the data center plan is not yet approved, it wasn't determined yet in which direction information will go along each cable. The cables are put so that each computer is connected with each one, perhaps through some other computers.
The person in charge of the cleaning the data center will be Claudia Ivanova, the janitor. She loves to tie cables into bundles using cable ties. For some reasons, she groups the cables sticking out of a computer into groups of two, and if it isn't possible, then she gets furious and attacks the computer with the water from the bucket.
It should also be noted that due to the specific physical characteristics of the Very Important Information, it is strictly forbidden to connect in one bundle two cables where information flows in different directions.
The management of the data center wants to determine how to send information along each cable so that Claudia Ivanova is able to group all the cables coming out of each computer into groups of two, observing the condition above. Since it may not be possible with the existing connections plan, you are allowed to add the minimum possible number of cables to the scheme, and then you need to determine the direction of the information flow for each cable (yes, sometimes data centers are designed based on the janitors' convenience...)
The person in charge of the cleaning the data center will be Claudia Ivanova, the janitor. She loves to tie cables into bundles using cable ties. For some reasons, she groups the cables sticking out of a computer into groups of two, and if it isn't possible, then she gets furious and attacks the computer with the water from the bucket.
It should also be noted that due to the specific physical characteristics of the Very Important Information, it is strictly forbidden to connect in one bundle two cables where information flows in different directions.
The management of the data center wants to determine how to send information along each cable so that Claudia Ivanova is able to group all the cables coming out of each computer into groups of two, observing the condition above. Since it may not be possible with the existing connections plan, you are allowed to add the minimum possible number of cables to the scheme, and then you need to determine the direction of the information flow for each cable (yes, sometimes data centers are designed based on the janitors' convenience...)
输入格式
The first line contains two numbers, $n$ and $m$ ( $1<=n<=100000$ , $1<=m<=200000$ ) — the number of computers and the number of the already present cables, respectively.
Each of the next lines contains two numbers $a_{i},b_{i}$ ( $1<=a_{i},b_{i}<=n$ ) — the indices of the computers connected by the $i$ -th cable. The data centers often have a very complex structure, so a pair of computers may have more than one pair of cables between them and some cables may connect a computer with itself.
Each of the next lines contains two numbers $a_{i},b_{i}$ ( $1<=a_{i},b_{i}<=n$ ) — the indices of the computers connected by the $i$ -th cable. The data centers often have a very complex structure, so a pair of computers may have more than one pair of cables between them and some cables may connect a computer with itself.
输出格式
In the first line print a single number $p$ ( $p>=m$ ) — the minimum number of cables in the final scheme.
In each of the next $p$ lines print a pair of numbers $c_{i},d_{i}$ ( $1<=c_{i},d_{i}<=n$ ), describing another cable. Such entry means that information will go along a certain cable in direction from $c_{i}$ to $d_{i}$ .
Among the cables you printed there should be all the cables presented in the original plan in some of two possible directions. It is guaranteed that there is a solution where $p$ doesn't exceed $500000$ .
If there are several posible solutions with minimum possible value of $p$ , print any of them.
In each of the next $p$ lines print a pair of numbers $c_{i},d_{i}$ ( $1<=c_{i},d_{i}<=n$ ), describing another cable. Such entry means that information will go along a certain cable in direction from $c_{i}$ to $d_{i}$ .
Among the cables you printed there should be all the cables presented in the original plan in some of two possible directions. It is guaranteed that there is a solution where $p$ doesn't exceed $500000$ .
If there are several posible solutions with minimum possible value of $p$ , print any of them.
输入输出样例
输入 #1
4 6 1 2 2 3 3 4 4 1 1 3 1 3
输出 #1
6 1 2 3 4 1 4 3 2 1 3 1 3
输入 #2
3 4 1 2 2 3 1 1 3 3
输出 #2
6 2 1 2 3 1 1 3 3 3 1 1 1
Picture for the first sample test. The tied pairs of cables are shown going out from the same point.
Picture for the second test from the statement. The added cables are drawin in bold.
Alternative answer for the second sample test:

Picture for the second test from the statement. The added cables are drawin in bold.
Alternative answer for the second sample test:

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted