CF38D.Vasya the Architect
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
曾经,瓦西娅玩过积木。这套积木中的所有积木都是规则的立方体形状。瓦西娅是一位富有天赋的建筑师,然而他所搭建的塔却总是倒塌。
我们来考虑一下搭建过程:瓦西娅每次取一块积木,将其放置在已建好的塔顶,使得该积木的各边与之前已使用的积木的各边保持平行。我们在瓦西娅放置第一块积木的水平平面上建立一个笛卡尔坐标系。那么,第 i 块积木在该平面上的投影是一个边与坐标轴平行的正方形,其对角顶点坐标分别为 (xi,1,yi,1) 和 (xi,2,yi,2)。这些积木由均匀塑料制成,边长为 a 的立方体积木的质量为 a3 克。
题目保证:除第一块积木外,瓦西娅放置的每一块积木都直接放在前一块积木之上,即前一块积木的上表面与后一块积木的下表面的交集面积恒为正值。
我们(包括瓦西娅在内)生活在一个遵循经典静力学规律的正常世界中。因此,若再放置一块积木,整座塔就可能因自身重量而坍塌。瓦西娅依次将立方体积木一块叠在另一块之上,直到至少有一块积木失去平衡并掉落为止;此时,瓦西娅会感到沮丧并停止建造。请输出所能构建的最大稳定塔所含积木的数量,即最大的整数 m,使得对每个从 1 到 m 的整数 k,仅由第 1,2,…,k 块积木构成的塔均保持稳定。
输入格式
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.
第一行输入文件包含一个整数 n(1 ≤ n ≤ 100),表示砖块的数量。接下来的 n 行中,每行包含四个数 xi,1, yi,1, xi,2, yi,2(满足 xi,1 = xi,2 且 ∣xi,1 − xi,2∣ = ∣yi,1 − yi,2∣),它们是第 i 块砖底面两个对角顶点的坐标。所有坐标的值均为整数,且其绝对值不超过 50。
砖块按瓦西亚放置的顺序给出。对于所有 i ≥ 2,保证第 i−1 块砖顶面与第 i 块砖底面的交集面积严格大于零。
输出格式
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
输入解题思路,AI测评打分。不知道怎么写?