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

【题意】

在这里输入题意

【题解】

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

【代码】

#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. ArcGIS Engine中添加点、线、面元素

    转自原文 ArcGIS Engine中添加点.线.面元素 此种方式为IElement的方式在axMapControl的GraphicsContainer中好绘制图形. //画点 IPoint pt = ...

  2. 父类与子类的virtual

    父类加了virtual,子类不需要加virtual,多余.加了也不会报错. 父类中不是virtual,子类是virtual,那么父类中的不是虚函数,子类及子子类的派生类中该函数才是虚函数

  3. How to install Armbian on Orange Pi Plus 2e

    bian on Orange Pi Plus 2e How to install Armbian on Orange Pi Plus 2e Armbian on the microSD You jus ...

  4. OpenCV —— 矩阵操作

    多通道的矩阵 —— 通道是连续的!! 要将指向该数据类型的指针移动到下一通道,我们只需要将其增加1.如果想访问下一个“像素”或者元素集,则需要一定的偏移量 矩阵的step元素是矩阵中行的长度,单位为字 ...

  5. jQuery插件--根据数据加载的进度动画案例

    css: *{ margin:; padding:; } @media screen and (min-width:320px){ html{font-size:12px;}} @media scre ...

  6. 2017国家集训队作业[agc006f]Blackout

    2017国家集训队作业[agc006f]Blackout 题意: 有一个\(N*N\)的网格,一开始有\(M\)个格子被涂黑,给出这\(M\)个格子,和染色操作:如果有坐标为\((x,y),(y,z) ...

  7. kali之Nmap (Network Mapper(网络映射器)

    Nmap是主机扫描工具,他的图形化界面是Zenmap,分布式框架为Dnamp. Nmap可以完成以下任务: 主机探测 端口扫描 版本检测 系统检测 支持探测脚本的编写 Nmap在实际中应用场合如下: ...

  8. Windows学习总结(5)——【IIS建站】Windows10怎么打开站点服务?

    从Windows8开始,界面发生了很大的变动,再到Windows10,仍然有不小的变动,鉴于以后Windows10会成为主流,我们姑且介绍下Windows10建站的方法,虽然它并不是专业的服务器系统, ...

  9. PatentTips - Transparent unification of virtual machines

    BACKGROUND Virtualization technology enables a single host computer running a virtual machine monito ...

  10. 如果笔记本的 WIN7 运行很卡,请尝试运行这些批处理

    如果笔记本的 WIN7 运行很卡,请尝试运行这些批处理 WIN7是不是很卡?关掉下列服务吧 @echo off rem AppXSvc 为部署应用商店应用程序提供基础结构支持 rem BITS 微软的 ...