【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

发现根本不用存节点信息。
遇到了叶子节点且为黑色,就直接覆盖矩阵就好(因为是并集);

【代码】

#include <bits/stdc++.h>
using namespace std; const int N = (1 << 5) + 10; string s;
int pos, bo[N][N]; void fugai(int x1, int y1, int x2, int y2) {
for (int i = x1; i <= x2; i++)
for (int j = y1; j <= y2; j++)
bo[i][j] = 1;
} void dfs(int x1, int y1, int x2, int y2) {
if (s[pos] == 'f' || s[pos] == 'e') {
if (s[pos] == 'f') {
fugai(x1, y1, x2, y2);
}
return;
}
int len = (x2 - x1 + 1) / 2;
pos++;
dfs(x1, y1 + len, x1 + len - 1, y1 + len + len - 1);
pos++;
dfs(x1, y1, x1 + len - 1, y1 + len - 1);
pos++;
dfs(x1 + len, y1, x1 + len + len - 1, y1 + len - 1);
pos++;
dfs(x1 + len, y1 + len, x1 + len + len - 1, y1 + len + len - 1);
} int main() {
//freopen("rush.txt", "r", stdin);
int T;
scanf("%d", &T);
while (T--) {
memset(bo, 0, sizeof bo);
cin >> s;
pos = 0;
dfs(1, 1, 32, 32);
cin >> s;
pos = 0;
dfs(1, 1, 32, 32);
int cnt = 0;
for (int i = 1; i <= 32; i++)
for (int j = 1; j <= 32; j++)
cnt += bo[i][j];
printf("There are %d black pixels.\n", cnt);
}
return 0;
}

【例题 6-11 UVA-297】Quadtrees的更多相关文章

  1. UVa 297 Quadtrees(树的递归)

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

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

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

  3. uva 297 quadtrees——yhx

    Quadtrees  A quadtree is a representation format used to encode images. The fundamental idea behind ...

  4. UVA 297 Quadtrees(四叉树建树、合并与遍历)

    <span style="font-size: 18pt; font-family: Arial, Helvetica, sans-serif; background-color: r ...

  5. UVa 297 Quadtrees -SilverN

    A quadtree is a representation format used to encode images. The fundamental idea behind the quadtre ...

  6. UVa 297 - Quadtrees

    题目:利用四叉树处理图片,给你两张黑白图片的四叉树,问两张图片叠加后黑色的面积. 分析:搜索.数据结构.把图片分成1024块1*1的小正方形,建立一位数组记录对应小正方形的颜色. 利用递归根据字符串, ...

  7. UVA - 297 Quadtrees (四分树)

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

  8. 297 - Quadtrees (UVa)

    Quadtrees A quadtree is a representation format used to encode images. The fundamental idea behind t ...

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

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

  10. 【紫书】Quadtrees UVA - 297 四叉树涂色

    题意:前序遍历给出两个像素方块.求两个方块叠加后有几个黑色格子. 题解:每次读进来一个方块,就在二维数组上涂色.每次把白色涂黑就cnt++: 具体递归方法是以右上角坐标与边长为参数,每次通过几何规律往 ...

随机推荐

  1. Linux 内核链表使用举例

    链表数据结构的定义非常简洁: struct list_head { struct list_head *next, *prev; }; list_head结构包括两个指向list_head结构的指针p ...

  2. 想学android进来看看吧~ ~

    我深知学校里面有非常多同学想学习新的知识,而苦于没有指导. 事实上我想说的是,非常多东西须要靠自己,须要借助度娘,谷歌的.当然有人指导是最好的了. 对于刚接触android是不是也想做出像以下的效果: ...

  3. win7中下mysql-5.6.22免安装配置

    windows下mysql免安装配置 1. 下载mysql免安装压缩包 下载mysql-5.6.22-winx64.zip 解压到本地D:\mysql-5.6.22-winx64 2. 修改配置文件 ...

  4. ASP.Net简单的交互案例

    控制器 using System; using System.Collections.Generic; using System.Linq; using System.Web; using Syste ...

  5. thinkphp5多文件上传如何实现

    thinkphp5多文件上传如何实现 一.总结 一句话总结:官方文档,测试一下,一定要测试,打印中间变量,就知道每句话是什么意思,一定要测试一下.又简单有快. 测试一下,你就能确定中间变量和你的是不是 ...

  6. dfs算法中求数列的组合

    /* 从13个书中挑选5个值,他们的组合可能是 什么, 如下代码 dfs深度遍历, 和全排列是一种方法,但是思路不同 */ public class Main { static int count = ...

  7. Whitening

    The goal of whitening is to make the input less redundant; more formally, our desiderata are that ou ...

  8. telint---切换当前正在运行的Linux系统的运行等级

    telint命令用于切换当前正在运行的Linux系统的运行等级 Send control commands to the init daemon. --help Show this help --no ...

  9. 怎样从Cortex-m向STM32移植使用SPI接口协议

    /*************************************************************************************************** ...

  10. Codeforces #258 Div.2 E Devu and Flowers

    大致题意: 从n个盒子里面取出s多花.每一个盒子里面的花都同样,而且每一个盒子里面花的多数为f[i],求取法总数. 解题思路: 我们知道假设n个盒子里面花的数量无限,那么取法总数为:C(s+n-1, ...