USACO 3.3.3 Packing Rectangles (packrec)(转)
来源:互联网 发布:牛仔裤推荐淘宝 编辑:程序博客网 时间:2024/05/19 12:14
报告:http://starforever.blog.hexun.com/2097115_d.html
因为只有4个方块,所以枚举每个方块的选择顺序和放置方向(横放还是纵放),放置方式只有题目给出的6种基本模式,分别算出不同模式下最小的面积,更新最优解。
第4、5个在本质上其实是一样。如图,不同模式对应的最小面积如下:
设w1,w2,w3,w4表示4个方块的横长,h1,h2,h3,h4表示4个方块的纵长。w,h表示最小。
1:w=w1+w2+w3+w4;h=max(h1,h2,h3,h4)
2:w=max(w1+w2+w3,w4);h=max(h1,h2,h3)+h4
3:w=max(w1+w2,w3)+w4;h=max(h1+h3,h2+h3,h4)
4:w=w1+w2+max(w3,w4);h=max(h1,h3+h4,h2)
5:h=max(h1+h3,h2+h4)
对于w,我们细分为如下四种形式:
(1):h3>=h2+h4;w=max(w1,w3+w2,w3+w4)
(2):h3>h4 and h3<h2+h4;w=max(w1+w2,w2+w3,w3+w4)
(3):h4>h3 and h4<h1+h3;w=max(w1+w2,w1+w4,w3+w4)
(4):h4>=h1+h3;w=max(w2,w1+w4,w3+w4)
*:h3=h4(图中没画);w=max(w1+w2,w3+w4)
用一个数组记录最优解,最后排序输出即可。
- USACO 3.3.3 Packing Rectangles (packrec)(转)
- USACO 1.4 Packing Rectangles (packrec)
- USACO6.2.2 Packing Rectangles(packrec)
- USACO--Packing Rectangles
- USACO 1.4-Packing Rectangles
- Packing Rectangles(USACO)
- [USACO] Packing Rectangles
- USACO Packing Rectangles [cheated]
- usaco Packing Rectangles
- USACO:PROB Packing Rectangles
- USACO Packing Rectangles
- USACO-Packing Rectangles
- USACO Packing Rectangles
- USACO 1.4 Packing Rectangles
- USACO s1.4 Packing Rectangles
- USACO 1.4.1 packing rectangles
- USACO 1.4.1Packing Rectangles
- [USACO 1.4.1] Packing Rectangles
- JVM调优总结-调优方法
- LESSON 9 E-MAIL SECURITY part I
- Linux中的静态链接库分析与使用
- 算法的时间复杂度
- linux gcc参数详解
- USACO 3.3.3 Packing Rectangles (packrec)(转)
- C/C++ 编译器和调试器以及静态库、动态库使用汇总
- 混合图的欧拉回路
- IK Analyzer 3 中文分词器的学习笔记
- SGU 242. Student's Morning
- 随机生成图片
- 做绅士的22个礼仪
- JAVA与C#
- saber