感觉特别像那个分治的日程表问题。是f的话就填,否则就不填,然后同一个表填两次。那么就是最后的结果。

 #include <iostream>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <stack>
#include <queue>
using namespace std;
const double Pi=3.14159265358979323846;
typedef long long ll;
const int MAXN=+;
const int dx[]={,,,,-};
const int dy[]={,-,,,};
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll mod=1e9+;
int a[MAXN][MAXN];
void build(string str,int &cnt,int r1,int r2,int c1,int c2)
{
char s=str[cnt++];
if(s=='p')
{
int midr=(r1+r2)/,midc=(c1+c2)/;
build(str,cnt,r1,midr,midc+,c2);
build(str,cnt,r1,midr,c1,midc);
build(str,cnt,midr+,r2,c1,midc);
build(str,cnt,midr+,r2,midc+,c2);
}
else if(s=='f')
{
//wcout <<"in";
for(int i=r1;i<=r2;i++)
for(int j=c1;j<=c2;j++)
a[i][j]=;
} } int main()
{
int t;cin>>t;
while(t--)
{
int cnt=;
string str1,str2;
cin>>str1>>str2;
memset(a,,sizeof(a));
build(str1,cnt,,,,);
/*for(int i=1;i<=32;i++)
{
for(int j=1;j<=32;j++)
{
cout <<a[i][j]<<" ";
}
cout <<endl;
}*/
cnt=;
build(str2,cnt,,,,);
int ans=;
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
{
if(a[i][j]) ans++;
} } printf("There are %d black pixels.\n",ans);
}
return ;
}

UVa 297 四分树的更多相关文章

  1. UVa 297 (四分树 递归) Quadtrees

    题意: 有一个32×32像素的黑白图片,用四分树来表示.树的四个节点从左到右分别对应右上.左上.左下.右下的四个小正方区域.然后用递归的形式给出一个字符串代表一个图像,f(full)代表该节点是黑色的 ...

  2. UVa 806 四分树

    题意: 分析: 类似UVa 297, 模拟四分树四分的过程, 就是记录一个左上角, 记录宽度wideth, 然后每次w/2这样递归下去. 注意全黑是输出0, 不是输出1234. #include &l ...

  3. UVA.297 Quadtrees (四分树 DFS)

    UVA.297 Quadtrees (四分树 DFS) 题意分析 将一个正方形像素分成4个小的正方形,接着根据字符序列来判断是否继续分成小的正方形表示像素块.字符表示规则是: p表示这个像素块继续分解 ...

  4. UVA - 297 Quadtrees (四分树)

    题意:求两棵四分树合并之后黑色像素的个数. 分析:边建树边统计. #include<cstdio> #include<cstring> #include<cstdlib& ...

  5. 四分树 (Quadtrees UVA - 297)

    题目描述: 原题:https://vjudge.net/problem/UVA-297 题目思路: 1.依旧是一波DFS建树 //矩阵实现 2.建树过程用1.0来填充表示像素 #include < ...

  6. UVa 297 Quadtrees(树的递归)

    Quadtrees 四分树就是一颗一个结点只有4个儿子或者没有儿子的树 [题目链接]UVa 297 Quadtrees [题目类型]树的递归 &题意: 一个图片,像素是32*32,给你两个先序 ...

  7. 搜索(四分树):BZOJ 4513 [SDOI2016 Round1] 储能表

    4513: [Sdoi2016]储能表 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 395  Solved: 213[Submit][Status] ...

  8. [C++]四分树(Quadtrees)

    [本博文非博主原创,思路与题目均摘自 刘汝佳<算法竞赛与入门经典(第2版)>] 四分树Quadtrees 一幅图有1024个点, 可以对图平均分成4块, 并且子图也可以再往下分, 直到一个 ...

  9. UVA806-Spatial Structures(四分树)

    Problem UVA806-Spatial Structures Accept:329  Submit:2778 Time Limit: 3000 mSec Problem Description ...

随机推荐

  1. MySQL— 索引,视图,触发器,函数,存储过程,执行计划,慢日志,分页性能

    一.索引,分页性能,执行计划,慢日志 (1)索引的种类,创建语句,名词补充(最左前缀匹配,覆盖索引,索引合并,局部索引等): import sys # http://www.cnblogs.com/w ...

  2. 数据库SQL优化大总结1之- 百万级数据库优化方案

    转载自:https://blog.csdn.net/wuhuagu_wuhuaguo/article/details/72875054

  3. go报错unimplemented: 64-bit mode not compiled in与mingw 64位安装报错ERROR res已解决

    问题一:cc1.exe: sorry, unimplemented: 64-bit mode not compiled in 参考:https://www.cnblogs.com/lesroad/p/ ...

  4. vue and jest测试

    测试Vue的filters方法: 局部: import Page from '../src/Page' it('filter', () => { const case = Page.filter ...

  5. Java作业:第一次过程性考核 ——长春职业技术学院 16级网络工程

    Java作业:第一次过程性考核 ••<结构化程序设计>•• 考核目标:初步了解Java基本语法规则,学习结构化程序设计思想. 码云链接:https://gitee.com/SoridoD/ ...

  6. 微信小程序-解决下拉刷新报错

    关于“enablePullDownRefresh”: “true” 一.使用方式 在 Page 中定义 onPullDownRefresh 处理函数,监听该页面用户下拉刷新事件.需要在 config ...

  7. yuv2mp4

    >您使用什么类型的YUV像素格式?最常见的格式是YUV4:2:0平面8位(YUV420p).您可以键入ffmpeg -pix_fmts以获取所有可用格式的列表.>什么是帧率?在我的例子中, ...

  8. Handler使用小结

    个人概念里面handler用来更新UI.一直有一个问题困恼我,为什么我在主线程里面创建一个Handler不需要传递传递Looper,而在一个子线程里面必须调用Looper.prepare, Loope ...

  9. oracle入门之基本数据类型

    1.char(size)存放字符串,它最大可以存放2000个字符,是定长. 举例说明: create table test1(name char(32));//test1表中的name字段最多存放32 ...

  10. Oracle学习DayOne(SQL初步)

    一.DML.DDL.DCL SQL语句分为以下三种类型: DML: Data Manipulation Language 数据操纵语言DDL: Data Definition Language 数据定 ...