A12145 | Ancient civilizations
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restrictions:
1. Every two locations of the same civilization are connected by a unique path of roads
2. No two locations from different civilizations may have road between them (explorers don't want to accidentally mix civilizations they are currently exploring)
3. Roads must be straight line segments
4. Since intersections are expensive to build, they don't want any two roads to intersect (that is, only common point for any two roads may be at some of locations)
Obviously all locations are different points in the plane, but explorers found out one more interesting information that may help you – no three locations lie on the same line!
Help explorers and find a solution for their problem, or report it is impossible.
1. Every two locations of the same civilization are connected by a unique path of roads
2. No two locations from different civilizations may have road between them (explorers don't want to accidentally mix civilizations they are currently exploring)
3. Roads must be straight line segments
4. Since intersections are expensive to build, they don't want any two roads to intersect (that is, only common point for any two roads may be at some of locations)
Obviously all locations are different points in the plane, but explorers found out one more interesting information that may help you – no three locations lie on the same line!
Help explorers and find a solution for their problem, or report it is impossible.
输入格式
In the first line, integer $n$ $(1 \leq n \leq 10^3)$ - the number of locations discovered.
In next $n$ lines, three integers $x, y, c$ $(0 \leq x, y \leq 10^4, c \in \{0, 1\})$ - coordinates of the location and number of civilization it belongs to.
In next $n$ lines, three integers $x, y, c$ $(0 \leq x, y \leq 10^4, c \in \{0, 1\})$ - coordinates of the location and number of civilization it belongs to.
输出格式
In first line print number of roads that should be built.
In the following lines print all pairs of locations (their $0$ -based indices) that should be connected with a road.
If it is not possible to build roads such that all restrictions are met, print "Impossible". You should not print the quotation marks.
In the following lines print all pairs of locations (their $0$ -based indices) that should be connected with a road.
If it is not possible to build roads such that all restrictions are met, print "Impossible". You should not print the quotation marks.
输入输出样例
输入 #1
5 0 0 1 1 0 0 0 1 0 1 1 1 3 2 0
输出 #1
3 1 4 4 2 3 0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted