感觉特别像那个分治的日程表问题。是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. JavaScript中的this详解

    前言 this用法说难不难,有时候函数调用时,往往会搞不清楚this指向谁?那么,关于this的用法,你知道多少呢? 下面我来给大家整理一下关于this的详细分析,希望对大家有所帮助! this指向的 ...

  2. 菜鸟使用MySQL存储过程and临时表,供新手参考,请高手斧正

    因为公司最近的一个项目,第一次用到了MySQL(5.10版本),之前听传说MySQL很厉害的样子,因为开源而神奇,但是现在用起来, 感觉并不好啊!我知道是我水平太down,呜呜呜,请各路神仙略施小技, ...

  3. win10 adb(Android Debug Bridge)导出日志

    百度了一下 各种设置环境变量.放到system32文件夹(64位系♂统放到C:\Windows\SysWOW64)等 公司电脑win10系统 方便多了 把环境变量设置啥的全删了 adb下载地址:htt ...

  4. 一款堪称完美的编程字体Source Code Pro

    对于程序员来说,好的字体应该满足的基本条件: 字母和数字易于分辨,如: 英文字母o 和 阿拉伯数字 0 ,或者 英文字母 l 和 阿拉伯数字 1 ,两个单引号 '' 和双引号 ”. 字体等宽,保持对齐 ...

  5. 在eclispe上git 代码滚回

    1.项目 - 鼠标右键 - team - show in history: 2.history窗口 - 选择需要回滚到的版本 - reset - hard:3.项目 - 鼠标右键 - team - p ...

  6. 第八次作业:聚类--K均值算法:自主实现与sklearn.cluster.KMeans调用

    import numpy as np x = np.random.randint(1,100,[20,1]) y = np.zeros(20) k = 3 def initcenter(x,k): r ...

  7. 杭电ACM1007

    Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  8. Python函数的一点用法

    #python的基本语法网上已经有很多详细的解释了,写在这里方便自己记忆一些 BIF是python内置的函数,任何一门语言都能用来创造函数,python也不例外 1.创建一个函数 def func() ...

  9. oo第3次博客作业

    一.规格化设计的发展历史 20世纪60年代,软件出现严重的危机Dijkstra提出了goto语句的危害,由此引发了软件界长达数年的论战,并产生了结构化的程序设计方法.随着计算机 技术的发展,结构设计化 ...

  10. protel dxp 2004安装与破解

    安装准备 压缩文件包内容: dxp2004汉化补丁 dxp2004元件库 Network License Setup网络版注册机 Protel DXP2004原程序 Protel2004_sp2_单机 ...