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

【题意】

在这里输入题意

【题解】

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

【代码】

#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. C# ArcGIS Engine 使当前选中的操作失效(清除当前鼠标事件)

    问题描述: 前提:我用的ENGINE9.3开发,拖了一个ToolbarControl控件,加了一些常用操作的工具(平移,放大,缩小)在上边. 问题:我做了一个增加点的按钮.当我平移完地图之后,点击增加 ...

  2. android5.x加入sim1,sim2标识

    1,mobile_signal_group.xml  ..... <FrameLayout android:id="@+id/mobile_combo" android:la ...

  3. Python 面向对象 —— super 的使用(Python 2.x vs Python 3.x)

    注意区分当前的 Python 版本是 2.X 还是 3.X,Python 3.X 在 super 的使用上较之 Python 2.X 有较大的变化: 1. Python 2.x class Conta ...

  4. 69.nodejs对mongodb数据库的增删改查操作

    转自:https://www.cnblogs.com/sexintercourse/p/6485381.html 首先要确保mongodb的正确安装,安装参照:http://docs.mongodb. ...

  5. JavaScript--数据结构与算法之图

    图和图的算法:图的定义:由边的集合及顶点的集合组成. 例如地图,每个城镇是顶点,道路是边,由顶点对来定义(城镇1,城镇2)简称(v1,v2)顶点也有权重——成本.基本概念: 有向图:图的顶点对是有序的 ...

  6. 小米开源文件管理器MiCodeFileExplorer-源码研究(9)-入口分析

    AndroidManifest.xml是Android应用程序最重要的配置文件. 入口文件和intent-filter <application android:icon="@draw ...

  7. Webservice银行报文接口设计

      Preface: 合理的软件架构设计其好处是不言而喻的,系统具有清晰的软件结构,良好的可扩展性,类的职能单一明确,系统的复杂度底.此前的一个实际项目中总结了些关于OO设计的实际应用,主要是围绕'高 ...

  8. *android抓包工具——fiddler抓包分析api接口

    本文地址:http://blog.csdn.net/u011733020 首先,写这个仅仅是为了学习.不是要做什么违法的事情,假设有问题,有关部门 请联系我,立刻删除. 不要查我水表. 正题:这里介绍 ...

  9. LeetCode 136 Single Number(仅仅出现一次的数字)

    翻译 给定一个整型数组,除了某个元素外其余元素均出现两次. 找出这个仅仅出现一次的元素. 备注: 你的算法应该是一个线性时间复杂度. 你能够不用额外空间来实现它吗? 原文 Given an array ...

  10. 17.Node.js 回调函数--异步编程

    转自:http://www.runoob.com/nodejs/nodejs-tutorial.html Node.js 异步编程的直接体现就是回调. 异步编程依托于回调来实现,但不能说使用了回调后程 ...