JZOJ 3807 【NOIP2014模拟8.25】地砖铺设
来源:互联网 发布:windows netsh wlan 编辑:程序博客网 时间:2024/04/28 00:02
地砖铺设
Description
给出一个长为
Data Constraint
Solution
贪心。
从上到下,从左到右对网格图进行构造,然后每次判断 与前面的格子进行合并构成一个更大的正方形更优 还是 该格子作为一个新的正方形的左上顶点更优,选最优方案构造即可。
Code(Pascal)
var ch:array[0..1000,0..1000] of char; x,y,ok,bc:array[0..1000,0..1000] of longint; n,m,j,k,l,i:longint; bz:array['A'..'E'] of boolean; cc:char;begin readln(n,m); for i:=0 to n+1 do for l:=0 to m+1 do ch[i,l]:=' '; for l:=0 to m+1 do ch[0,l]:='E'; for l:=0 to n+1 do ch[l,0]:='E'; for i:=1 to n do begin for l:=1 to m do begin if ch[i,l]<>' ' then continue; ok[i,l]:=1; fillchar(bz,sizeof(bz),true); bz[ch[i,l-1]]:=false; bz[ch[i-1,l]]:=false; if ch[i,l+1]<>' ' then bz[ch[i,l+1]]:=false; for cc:='A' to 'E' do if bz[cc] then break; bc[i,l]:=1; if ch[i,l-1]>cc then ch[i,l]:=cc else if (ok[i,l-1]=1) and (ch[i-1,l]<>ch[i,l-1]) and (i+bc[i,l-1]<=n) then begin for j:=1 to bc[i,l-1] do ch[i+j-1,l]:=ch[i,l-1]; bc[i,l]:=bc[i,l]+bc[i,l-1]; for j:=l downto l-bc[i,l-1] do ch[i+bc[i,l-1],j]:=ch[i,l-1]; end else ch[i,l]:=cc; end; end; for i:=1 to n do begin for l:=1 to m do write(ch[i,l]); writeln; end;end.
1 0
- JZOJ 3807 【NOIP2014模拟8.25】地砖铺设
- JZOJ 3807. 【NOIP2014模拟8.25】地砖铺设
- JZOJ 3807. 【NOIP2014模拟8.25】地砖铺设
- 【NOIP2014模拟8.25】地砖铺设
- 【JZOJ 3807】地砖铺设
- 【JZOJ3807】地砖铺设
- JZOJ 3808. 【NOIP2014模拟8.25】道路值守
- JZOJ 3809. 【NOIP2014模拟8.25】设备塔
- JZOJ 3809. 【NOIP2014模拟8.25】设备塔
- JZOJ 3808 【NOIP2014模拟8.25】道路值守
- JZOJ 3809 【NOIP2014模拟8.25】设备塔
- JZOJ NOIP2014模拟 8.12
- JZOJ NOIP2014模拟 8.13
- jzoj NOIP2014提高组模拟8.9总结
- [JZOJ 3794]. 【NOIP2014模拟8.20】高级打字机
- 【JZOJ】 【NOIP2014】【模拟试题】保镖排队
- JZOJ 3814. 【NOIP2014模拟9.7】天黑黑
- JZOJ 3823. 【NOIP2014模拟9.9】遇见
- 洛谷 P1086 花生采摘
- Cocos2d-JS 2017.1.16-代码阅读笔记
- 微信相框plus详细体验
- 沃美冲出战阵召唤出广宇神兽
- 杂记
- JZOJ 3807 【NOIP2014模拟8.25】地砖铺设
- codeforces 755E PolandBall and White-Red graph
- QCustomplot使用分享(四) QCPAbstractItem
- SpringBoot -- 服务网关APIGateway
- Nginx学习总结(7)——Nginx配置HTTPS 服务器
- Linux Shell自动交互的三种方法
- spring整合redis
- Android源码 从runOnUiThread聊聊消息机制
- vi的撤销命令