poj 3314 Plaque Pack, 模拟
来源:互联网 发布:html是不是编程语言 编辑:程序博客网 时间:2024/05/22 15:21
题意:n个形状,宽度均为w,推入宽度为w高度为b的盒子中,如果装不下了就放入一个新盒子里,输出每个盒子占用的高度。
直接模拟就行,就是处理起来有点复杂,具体看代码吧。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char sh[111][15][15];char box[111][15];int th[111];int cnput(char sh[][15], int dp, int h, int b) { int i, j, k; i = h - 1; j = dp; while(i >= 0) { for(k = 0; k < b; k++) { if(sh[i][k] == 'X' && box[j][k] == 'X') return 0; } i--; j--; } return 1;}void putin(char sh[][15], int dp, int h, int w) { int i, j, k; i = h - 1; j = dp; while(i >= 0) { for(k = 0; k < w; k++) { if(sh[i][k] == 'X' || box[j][k] == 'X') box[j][k] = 'X'; else box[j][k] = '.'; } i--; j--; }}int main() { int n, w, b, h, i, j; while(~scanf("%d%d%d", &n, &w, &b) && (n || w || b)) { int ans = 0, t, hs = 0; memset(box, 0, sizeof(box)); for(i = 0; i < n; i++) { scanf("%d", &th[i]); for(j = 0; j < th[i]; j++) scanf("%s", sh[i][j]); if(!i) { ans = th[i]; memcpy(box + b - th[i], sh[i], sizeof(sh[i])); continue; } int cnp = 1; for(j = max(b - 1 - ans, th[i] - 1); j <= b; j++) { if(j == b || !cnput(sh[i], j, th[i], w)) { if(j - 1 < th[i] - 1) break; putin(sh[i], j - 1, th[i], w); cnp = 0; ans = max(ans, (b - j) + th[i]); break; } } if(cnp) { if(hs) printf(" "); else hs = 1; printf("%d", ans); ans = th[i]; memset(box, 0, sizeof(box)); memcpy(box + b - th[i], sh[i], sizeof(sh[i])); } } if(hs) printf(" "); printf("%d\n", ans); } return 0;}
0 0
- poj 3314 Plaque Pack, 模拟
- POJ 3314 Plaque Pack (模拟)
- Sicily 1407. Plaque Pack
- C语言模拟类和pack例子
- pack()
- PACK
- pack
- pack
- noip模拟赛(10.4) 背包(pack)
- POJ 1017 模拟啊模拟
- POJ 1565 水 模拟
- Poj 模拟题
- POJ 1068 括号模拟
- POJ 2453 简单模拟
- POJ 2833 简单模拟
- POJ 1016 模拟题
- 模拟退火 poj 1379
- poj 1379 模拟退火
- 理解 iOS 的内存管理
- 序列中增序列的最大个数
- Python 中的循环与 else
- 关于Rs485通信只能接收不能发送的问题
- CentOS和WIN7双系统时间错误
- poj 3314 Plaque Pack, 模拟
- 拓扑排序
- Oracle安装后命令行中运行sqlplus / as sysdba出现错误ora-01031:insufficient privileges
- shell排序
- 2016.08.18【初中部 NOIP普及组 】模拟赛题目
- 2016多校第二场
- 关于学Android常用布局的感想
- MySQL获取数据库每个表的行数
- 【组合数学】POJ_1850_Code