A1150 | [COCI-2008_2009-contest2]#1 CAVLI
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Mirko found a wooden board and N nails in his attic. Mirko hammered the nails into the board as fast as possible. The board can be modeled by a coordinate plane and the nails as points in it. No two nails have the same x or the same y coordinate.
In order to keep having fun, Mirko stole his sister's elastic hair band, spread it over all nails and then let go. The elastic, naturally, tightened around the nails.
Mirko then repeats these steps while there are at least three nails in the board:
1. Write down the area of the shape enclosed by the hair band.
2. Picks the leftmost, rightmost, topmost or bottommost nail in the board.
3. Remove the chosen nail from the board; the elastic tightens again around the remaining nails.
Write a program that calculates the numbers written in step 1 of each iteration, if we know the nail Mirko picks in step 2 of each iteration.
In order to keep having fun, Mirko stole his sister's elastic hair band, spread it over all nails and then let go. The elastic, naturally, tightened around the nails.
Mirko then repeats these steps while there are at least three nails in the board:
1. Write down the area of the shape enclosed by the hair band.
2. Picks the leftmost, rightmost, topmost or bottommost nail in the board.
3. Remove the chosen nail from the board; the elastic tightens again around the remaining nails.
Write a program that calculates the numbers written in step 1 of each iteration, if we know the nail Mirko picks in step 2 of each iteration.
输入格式
The first line contains the integer N (3 ≤ N ≤ 300000), the number of nails.
Each of the following N lines contains two integers separated by a space, the coordinates of a nail. All coordinates will be between 1 and 100000000
0. No two nails will share the same x or y coordinate.
The next line contains N-2 letters 'L', 'R', 'U' or 'D'. The letters represent the nails Mirko picked in order:
• 'L' for the leftmost nail (smallest x coordinate),
• 'R' for the rightmost nail (largest x coordinate),
• 'U' for the topmost nail (largest y coordinate),
• 'D' for the bottommost nail (smallest y coordinate).
Each of the following N lines contains two integers separated by a space, the coordinates of a nail. All coordinates will be between 1 and 100000000
0. No two nails will share the same x or y coordinate.
The next line contains N-2 letters 'L', 'R', 'U' or 'D'. The letters represent the nails Mirko picked in order:
• 'L' for the leftmost nail (smallest x coordinate),
• 'R' for the rightmost nail (largest x coordinate),
• 'U' for the topmost nail (largest y coordinate),
• 'D' for the bottommost nail (smallest y coordinate).
输出格式
Output N-2 numbers, each on a separate line. The numbers are, in order, the areas that Mirko wrote down. Output numbers with one digit after the decimal point.
输入输出样例
输入 #1
5 1 4 2 2 4 1 3 5 5 3 LUR
输出 #1
9.0 6.5 2.5
输入 #2
8 1 6 2 4 3 1 4 2 5 7 6 5 7 9 8 3 URDLUU
输出 #2
34.0 24.0 16.5 14.0 9.5 5.0
In test cases worth 50% points, N will be less than 1000.
The images below illustrate the state before each of the 6 steps in the second example.
The images below illustrate the state before each of the 6 steps in the second example.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted