A10750 | Arpa’s overnight party and Mehrdad’s silent entering
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Note that girls in Arpa’s land are really attractive.
Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw $n$ pairs of friends sitting around a table. $i$ -th pair consisted of a boy, sitting on the $a_{i}$ -th chair, and his girlfriend, sitting on the $b_{i}$ -th chair. The chairs were numbered $1$ through $2n$ in clockwise direction. There was exactly one person sitting on each chair.
There were two types of food: Kooft and Zahre-mar. Now Mehrdad wonders, was there any way to serve food for the guests such that:
- Each person had exactly one type of food,
- No boy had the same type of food as his girlfriend,
- Among any three guests sitting on consecutive chairs, there was two of them who had different type of food. Note that chairs $2n$ and $1$ are considered consecutive.
Find the answer for the Mehrdad question. If it was possible, find some arrangement of food types that satisfies the conditions.
Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw $n$ pairs of friends sitting around a table. $i$ -th pair consisted of a boy, sitting on the $a_{i}$ -th chair, and his girlfriend, sitting on the $b_{i}$ -th chair. The chairs were numbered $1$ through $2n$ in clockwise direction. There was exactly one person sitting on each chair.
There were two types of food: Kooft and Zahre-mar. Now Mehrdad wonders, was there any way to serve food for the guests such that:
- Each person had exactly one type of food,
- No boy had the same type of food as his girlfriend,
- Among any three guests sitting on consecutive chairs, there was two of them who had different type of food. Note that chairs $2n$ and $1$ are considered consecutive.
Find the answer for the Mehrdad question. If it was possible, find some arrangement of food types that satisfies the conditions.
输入格式
The first line contains an integer $n$ ( $1<=n<=10^{5}$ ) — the number of pairs of guests.
The $i$ -th of the next $n$ lines contains a pair of integers $a_{i}$ and $b_{i}$ ( $1<=a_{i},b_{i}<=2n$ ) — the number of chair on which the boy in the $i$ -th pair was sitting and the number of chair on which his girlfriend was sitting. It's guaranteed that there was exactly one person sitting on each chair.
The $i$ -th of the next $n$ lines contains a pair of integers $a_{i}$ and $b_{i}$ ( $1<=a_{i},b_{i}<=2n$ ) — the number of chair on which the boy in the $i$ -th pair was sitting and the number of chair on which his girlfriend was sitting. It's guaranteed that there was exactly one person sitting on each chair.
输出格式
If there is no solution, print -1.
Otherwise print $n$ lines, the $i$ -th of them should contain two integers which represent the type of food for the $i$ -th pair. The first integer in the line is the type of food the boy had, and the second integer is the type of food the girl had. If someone had Kooft, print $1$ , otherwise print $2$ .
If there are multiple solutions, print any of them.
Otherwise print $n$ lines, the $i$ -th of them should contain two integers which represent the type of food for the $i$ -th pair. The first integer in the line is the type of food the boy had, and the second integer is the type of food the girl had. If someone had Kooft, print $1$ , otherwise print $2$ .
If there are multiple solutions, print any of them.
输入输出样例
输入 #1
3 1 4 2 5 3 6
输出 #1
1 2 2 1 1 2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted