A9702 | Crazy Town
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Crazy Town is a plane on which there are $n$ infinite line roads. Each road is defined by the equation $a_{i}x+b_{i}y+c_{i}=0$ , where $a_{i}$ and $b_{i}$ are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the point where at least two different roads intersect.
Your home is located in one of the blocks. Today you need to get to the University, also located in some block. In one step you can move from one block to another, if the length of their common border is nonzero (in particular, this means that if the blocks are adjacent to one intersection, but have no shared nonzero boundary segment, then it are not allowed to move from one to another one in one step).
Determine what is the minimum number of steps you have to perform to get to the block containing the university. It is guaranteed that neither your home nor the university is located on the road.
Your home is located in one of the blocks. Today you need to get to the University, also located in some block. In one step you can move from one block to another, if the length of their common border is nonzero (in particular, this means that if the blocks are adjacent to one intersection, but have no shared nonzero boundary segment, then it are not allowed to move from one to another one in one step).
Determine what is the minimum number of steps you have to perform to get to the block containing the university. It is guaranteed that neither your home nor the university is located on the road.
输入格式
The first line contains two space-separated integers $x_{1}$ , $y_{1}$ ( $-10^{6}<=x_{1},y_{1}<=10^{6}$ ) — the coordinates of your home.
The second line contains two integers separated by a space $x_{2}$ , $y_{2}$ ( $-10^{6}<=x_{2},y_{2}<=10^{6}$ ) — the coordinates of the university you are studying at.
The third line contains an integer $n$ ( $1<=n<=300$ ) — the number of roads in the city. The following $n$ lines contain 3 space-separated integers ( $-10^{6}<=a_{i},b_{i},c_{i}<=10^{6}$ ; $|a_{i}|+|b_{i}|>0$ ) — the coefficients of the line $a_{i}x+b_{i}y+c_{i}=0$ , defining the $i$ -th road. It is guaranteed that no two roads are the same. In addition, neither your home nor the university lie on the road (i.e. they do not belong to any one of the lines).
The second line contains two integers separated by a space $x_{2}$ , $y_{2}$ ( $-10^{6}<=x_{2},y_{2}<=10^{6}$ ) — the coordinates of the university you are studying at.
The third line contains an integer $n$ ( $1<=n<=300$ ) — the number of roads in the city. The following $n$ lines contain 3 space-separated integers ( $-10^{6}<=a_{i},b_{i},c_{i}<=10^{6}$ ; $|a_{i}|+|b_{i}|>0$ ) — the coefficients of the line $a_{i}x+b_{i}y+c_{i}=0$ , defining the $i$ -th road. It is guaranteed that no two roads are the same. In addition, neither your home nor the university lie on the road (i.e. they do not belong to any one of the lines).
输出格式
Output the answer to the problem.
输入输出样例
输入 #1
1 1 -1 -1 2 0 1 0 1 0 0
输出 #1
2
输入 #2
1 1 -1 -1 3 1 0 0 0 1 0 1 1 -3
输出 #2
2
Pictures to the samples are presented below (A is the point representing the house; B is the point representing the university, different blocks are filled with different colors):
 
 
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted