A7926 | Vasya the Architect
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Once Vasya played bricks. All the bricks in the set had regular cubical shape. Vasya vas a talented architect, however the tower he built kept falling apart.
Let us consider the building process. Vasya takes a brick and puts it on top of the already built tower so that the sides of the brick are parallel to the sides of the bricks he has already used. Let's introduce a Cartesian coordinate system on the horizontal plane, where Vasya puts the first brick. Then the projection of brick number $i$ on the plane is a square with sides parallel to the axes of coordinates with opposite corners in points $(x_{i,1},y_{i,1})$ and $(x_{i,2},y_{i,2})$ . The bricks are cast from homogeneous plastic and the weight of a brick $a×a×a$ is $a^{3}$ grams.
It is guaranteed that Vasya puts any brick except the first one on the previous one, that is the area of intersection of the upper side of the previous brick and the lower side of the next brick is always positive.
We (Vasya included) live in a normal world where the laws of physical statics work. And that is why, perhaps, if we put yet another brick, the tower will collapse under its own weight. Vasya puts the cubes consecutively one on top of the other until at least one cube loses the balance and falls down. If it happens, Vasya gets upset and stops the construction. Print the number of bricks in the maximal stable tower, that is the maximal number $m$ satisfying the condition that all the towers consisting of bricks 1, 2, ..., $k$ for every integer $k$ from 1 to $m$ remain stable.
Let us consider the building process. Vasya takes a brick and puts it on top of the already built tower so that the sides of the brick are parallel to the sides of the bricks he has already used. Let's introduce a Cartesian coordinate system on the horizontal plane, where Vasya puts the first brick. Then the projection of brick number $i$ on the plane is a square with sides parallel to the axes of coordinates with opposite corners in points $(x_{i,1},y_{i,1})$ and $(x_{i,2},y_{i,2})$ . The bricks are cast from homogeneous plastic and the weight of a brick $a×a×a$ is $a^{3}$ grams.
It is guaranteed that Vasya puts any brick except the first one on the previous one, that is the area of intersection of the upper side of the previous brick and the lower side of the next brick is always positive.
We (Vasya included) live in a normal world where the laws of physical statics work. And that is why, perhaps, if we put yet another brick, the tower will collapse under its own weight. Vasya puts the cubes consecutively one on top of the other until at least one cube loses the balance and falls down. If it happens, Vasya gets upset and stops the construction. Print the number of bricks in the maximal stable tower, that is the maximal number $m$ satisfying the condition that all the towers consisting of bricks 1, 2, ..., $k$ for every integer $k$ from 1 to $m$ remain stable.
输入格式
The first input file contains an integer $n$ ( $1<=n<=100$ ) which is the number of bricks. Each of the next $n$ lines contains four numbers $x_{i,1},y_{i,1},x_{i,2},y_{i,2}$ ( $x_{i,1}≠x_{i,2},|x_{i,1}-x_{i,2}|=|y_{i,1}-y_{i,2}|$ ) which are the coordinates of the opposite angles of the base of the brick number $i$ . The coordinates are integers and their absolute value does not exceed $50$ .
The cubes are given in the order Vasya puts them. It is guaranteed that the area of intersection of the upper side of the brick number $i-1$ and the lower side of the brick number $i$ is strictly strictly greater than zero for all $i>=2$ .
The cubes are given in the order Vasya puts them. It is guaranteed that the area of intersection of the upper side of the brick number $i-1$ and the lower side of the brick number $i$ is strictly strictly greater than zero for all $i>=2$ .
输出格式
Print the number of bricks in the maximal stable tower.
输入输出样例
输入 #1
2 0 0 3 3 1 0 4 3
输出 #1
2
输入 #2
2 0 0 3 3 2 0 5 3
输出 #2
1
输入 #3
3 0 0 3 3 1 0 4 3 2 0 5 3
输出 #3
3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted