感觉特别像那个分治的日程表问题。是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. [BZOJ3167]Sao

    Problem 给你n个任务,n-1个关系,ab代表a在b前或者a在b后 问你有几种拓扑序 Solution f[i][j]表示第i个节点前有j个节点的方案数 设当前节点为x,儿子节点为s,若x依赖于 ...

  2. FORTH 发展(部分)

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  3. linux下jdk8安装

    --- 解压命令不管用 添加插件 yum install tar --- 上传命令不管用 添加插件 wget http://www.ohse.de/uwe/releases/lrzsz-0.12.20 ...

  4. vue-cli项目多页面配置

    参考 : https://www.jianshu.com/p/0a30aca71b16

  5. leetcode python 037 求解数独

    import numpy as npimport syssys.setrecursionlimit(1000) #例如这里设置为一百万 def get1(n):    if n<3:       ...

  6. 小飞侠带你精通Python网络编程系列03-Python版本的选择

    1. 目前Python有两个主要版本Python2.X和Python3.X 2. Python2.X最后一个版本是2.7,目前(2018年10月21日)Python3.X最新版本为3.7 3. 很不幸 ...

  7. angularjs i18n

    <!doctype html><html ng-app="myApp"><head>    <meta charset="utf ...

  8. ansible资产配置

    参考链接:https://www.cnblogs.com/iois/p/6403761.html ansible主机组的使用,我们在对一个集群进行管理的时候集群会有很多角色,在执行统一命令操作的时候我 ...

  9. DevExpress WinForms使用教程:皮肤颜色和LookAndFeel

    [DevExpress WinForms v18.2下载] v18.2版本中更改了控制背景颜色和皮肤一起处理的方式.在v18.1中引入了Project Settings页面,其中包含一个skin se ...

  10. Docker数据卷持久化

    Docker提供三种不同的方式将数据从宿主机挂载到容器中:volumes,bind mounts和tmpfs. volumes:Docker管理宿主机文件系统的一部分(/var/lib/docker/ ...