hdu 4819 二维线段树,单点修改区间查询

安卓逆向实战:利用Frida-RPC自动化获取大麦演唱会数据 本文详细介绍了如何利用Frida-RPC技术实现安卓逆向自动化,以获取大麦演唱会数据。通过实战演示,从环境搭建、使用Frida动态分析定位核心签名算法,到封装为可复用的Python脚本,完整解析了自动化数据获取的技术路径与工程化思考。 阅读详情


Mosaic

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)
Total Submission(s): 916    Accepted Submission(s): 402


Problem Description
The God of sheep decides to pixelate some pictures (i.e., change them into pictures with mosaic). Here's how he is gonna make it: for each picture, he divides the picture into n x n cells, where each cell is assigned a color value. Then he chooses a cell, and checks the color values in the L x L region whose center is at this specific cell. Assuming the maximum and minimum color values in the region is A and B respectively, he will replace the color value in the chosen cell with floor((A + B) / 2).

Can you help the God of sheep?
 

Input
The first line contains an integer T (T ≤ 5) indicating the number of test cases. Then T test cases follow.

Each test case begins with an integer n (5 < n < 800). Then the following n rows describe the picture to pixelate, where each row has n integers representing the original color values. The j-th integer in the i-th row is the color value of cell (i, j) of the picture. Color values are nonnegative integers and will not exceed 1,000,000,000 (10^9).

After the description of the picture, there is an integer Q (Q ≤ 100000 (10^5)), indicating the number of mosaics.

Then Q actions follow: the i-th row gives the i-th replacement made by the God of sheep: xi, yi, Li (1 ≤ xi, yi ≤ n, 1 ≤ Li < 10000, Li is odd). This means the God of sheep will change the color value in (xi, yi) (located at row xi and column yi) according to the Li x Li region as described above. For example, an query (2, 3, 3) means changing the color value of the cell at the second row and the third column according to region (1, 2) (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4). Notice that if the region is not entirely inside the picture, only cells that are both in the region and the picture are considered.

Note that the God of sheep will do the replacement one by one in the order given in the input.
 

Output
For each test case, print a line "Case #t:"(without quotes, t means the index of the test case) at the beginning.

For each action, print the new color value of the updated cell.
 

Sample Input
  
1 3 1 2 3 4 5 6 7 8 9 5 2 2 1 3 2 3 1 1 3 1 2 3 2 2 3
 

Sample Output
  
Case #1: 5 6 3 4 6
 

Source
 

Recommend
liuyiding   |   We have carefully selected several similar problems for you:   5201  5200  5199  5198  5197 
 

二维线段树题。

二维线段树有两种,一种是线段树嵌套线段树。第二种是矩形树,将区间分成上下左右两个区间

第一种,常数较小速度比较快写起来也相对没那么长。但是缺点是外层线段树无法懒惰更新(或者是我不会吧?),只能用于区间查询单点更新或者单点查询区间更新。

第二种,常数大速度慢情况比较多,但是能懒惰更新,因为其实还是同一个线段树,只不过二叉变为四叉罢了。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define maxn 801
#define inf 0x3f3f3f3f
int maxi[maxn*3][maxn*3];
int mini[maxn*3][maxn*3];
int a[maxn][maxn];
int n;
int val;  //修改的值
int x, y; //修改点,设为全局变量就不用传到参数里
int x1, x2, y1, y2; //查询的区间
int crx;  //只表示一行的外层线段树节点编号
int cmax, cmin; //记录查询区间的最大值最小值

void buildy(int rx, int ry, int l, int r)
{
  if(l == r){
    if(rx == crx){        //外层线段树只表示一行,l==r,则这个为点,直接赋值
        maxi[rx][ry] = mini[rx][ry] = a[x][l];
    }
    else{                 //外层线段树是一段,则为一列的值,所以由rx(外层)的左子树和右子树更新(也就是同一列的上下区域)
        int lrx = rx<<1, rrx = rx<<1|1;       
        maxi[rx][ry] = max(maxi[lrx][ry], maxi[rrx][ry]);
        mini[rx][ry] = min(mini[lrx][ry], mini[rrx][ry]);
    }
    return;
  }

  int m =(l+r)>>1;
  int lc = ry<<1, rc = ry<<1|1;
  buildy(rx, lc, l, m);
  buildy(rx, rc, m+1,r);
  maxi[rx][ry] = max(maxi[rx][lc], maxi[rx][rc]);
  mini[rx][ry] = min(mini[rx][lc], mini[rx][rc]);
}

void buildx(int rx, int l, int r)
{
  int m = (l+r)>>1;
  if(r > l){
    buildx(rx<<1, l, m);
    buildx(rx<<1|1, m+1,r);
  }
  if(l == r) {crx = rx; x = l;}
  buildy(rx, 1, 1, n);
}

void updatey(int rx, int ry, int l, int r)
{
  if(l == r){
    if(rx == crx)
        maxi[rx][ry] = mini[rx][ry] = val;
    else{
        int lrx = rx<<1, rrx = rx<<1|1;
        maxi[rx][ry] = max(maxi[lrx][ry], maxi[rrx][ry]);
        mini[rx][ry] = min(mini[lrx][ry], mini[rrx][ry]);
    }
    return;
  }

  int m = (l+r)>>1;
  int lc = ry<<1, rc =ry<<1|1;
  if(y <= m)
    updatey(rx, lc, l, m);
  else
    updatey(rx, rc, m+1, r);
  maxi[rx][ry] = max(maxi[rx][lc], maxi[rx][rc]);
  mini[rx][ry] = min(mini[rx][lc], mini[rx][rc]);
}

void updatex(int rx, int l, int r)
{
  int m = (l+r)>>1;
  int lc = rx<<1, rc =rx<<1|1;
  if(r > l){
    if(x <= m)
        updatex(lc, l ,m);
    else
        updatex(rc, m+1, r);
  }
  if(l == r) crx = rx;
  updatey(rx, 1, 1, n);
}

void qy(int rx, int ry, int l, int r)
{
  if(y1 <= l && y2 >= r){
    cmin = min(cmin, mini[rx][ry]);
    cmax = max(cmax, maxi[rx][ry]);
    return;
  }

  int m = (l+r)>>1;
  int lc = ry<<1, rc =ry<<1|1;
  if(y1 <= m)
    qy(rx, lc, l, m);
  if(y2 > m)
    qy(rx, rc, m+1, r);
}

void qx(int rx, int l, int r)
{
  if(x1 <= l && x2 >= r){
    qy(rx, 1, 1, n);
    return;
  }


  int m = (l+r)>>1;
  int lc = rx<<1, rc =rx<<1|1;
  if(x1 <= m)
    qx(lc, l, m);
  if(x2 > m)
    qx(rc, m+1, r);

}

int main()
{
  int t, cnt = 1;
  scanf("%d", &t);
  while(t--){
    memset(maxi, -inf, sizeof(maxi));
    memset(mini, inf, sizeof(mini));
    printf("Case #%d:\n", cnt++);

    scanf("%d", &n);
    buildx(1, 1, n);
    for(int i = 1; i<=n; i++)
      for(int j=1; j<=n; j++)
        scanf("%d", &a[i][j]);
    buildx(1, 1, n);

    int  l;
    int q;
    scanf("%d",&q);
    while(q--){
      scanf("%d%d%d", &x, &y, &l);
      l>>=1;
      x1 = max(1, x-l); x2 = min(n, x+l);
      y1 = max(1, y-l); y2 = min(n, y+l);
      cmax = -inf, cmin = inf; qx(1, 1, n);
      val = (cmin+cmax)>>1;
      printf("%d\n", val);
      crx=-1; updatex(1, 1, n);
    }
  }
}



混合部署 操作系统混合部署 在openEuler Embedded 22.03中,已经集成了OpenAMP相关支持,并与openEuler的SIG Zephyr合作实现了openEuler Embedded与实时操作系统Zephyr在QEMU平台上的混合部署。具体的混合部署方式取决于设备的硬件和软件支持。例如,可以使用虚拟机软件(如VirtualBox)在Linux操作系统上运行Android虚拟机,从而实现Linux和Android的混合部署。需要注意的是,混合部署涉及到设备的硬件和软件兼容性,以及操作系统的配置和管理。 阅读详情

相关推荐

neruolib全脑建模计算框架

neurolib 是一个用python编写的全脑建模计算框架,也是可扩展的、允许轻松实现自定义神经质量模型,能够在介观尺度上表示脑区平均活动。

Rootfyx的博客 1147

线段树详解(单点修改+区间修改和查询)

【...】 把之前做的线段树的理论总结做了一个整合和一点修改。 线段树不能只是会用板子而已,要理解并且熟练,不假思索分分钟就能敲出来才行。 单点修改+区间修改和查询 例题+代码 目录 【线段树】 【引入】 【概述】 【单点修改和查询】 【建树】 【单点修改】 【区间查询最小值】 【区间查询区间和】 【区间修改和查询】 【延迟标记】 【标记下传】 【标记永久化】 ...

菜鸡成长史 1万+

DoubletFinder实战:如何优化参数提升scRNA-seq双细胞识别准确率?

本文深入探讨了如何通过优化DoubletFinder参数提升scRNA-seq双细胞识别准确率。详细解析了pK和nExp参数的影响机制,提供了系统化的参数优化流程和多样本整合策略,并结合真实数据集演示了验证方法与高级应用场景,帮助研究人员获得更可靠的分析结果。

weixin_28523493的博客 339

HDU 4819 —— Mosaic(二维线段树)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=4819

hongrock的专栏 738

使用openMVS对样例数据进行重建

openMVS根据github上的步骤进行编译。注意,如果没有GPU,用不了CUDA的话,那么需要在openMVS目录下找到CmakeLists.txt文件,把CUDA设置为OFF: SET(OpenMVS_USE_CUDA OFF CACHE BOOL "Enable CUDA library") 可执行的文件生成在openMVS_build/bin/里面,在openMVS_build文件夹下打开终端,按照顺序执行如下命令即可逐步重建。其中,-w 设置的是数据的总路径,-i 后接输入的文件名,-o

YuhsiHu的博客 2886

华为S5720交换机堆叠配置

S5720交换机,做下堆叠,两条线,交叉互联(即A交换机23口连到B交换机24口,A交换机24口连接B交换机23口)。PS:S5720堆叠可基于电口或者光口做,本次测试基于电口。 SWA配置 # 改名 [Huawei]sysname SWA # 最好先shutdown接口 [SWA]interface GigabitEthernet 0/0/23 [SWA-GigabitEthernet0/0/23]shutdown [SWA-GigabitEthernet0/0/23]interface G.

Markdown 6340

HDU---4819:Mosaic【二维线段树】

题意: 给定一个N*N的矩阵,每个格子都有一个数,再给出Q个询问,每次询问以(x,y)为中心的边长为L的正方形矩阵中的最大值和最小值,并修改(x,y)的值为(MAX+MIN)/2 分析: 1)四叉树 对于查询矩阵的最值+修改问题,考虑二维线段树,参照一维线段树的写法:每次将区间二分成两个子区间,对应矩阵应对X,Y同时二分,也就是4个子矩阵,即左上、右上、左下,右下四部分,所以要建一颗四叉树...

KobeDuu 444

【Python爬虫案例教学】超简洁代码采集原神所有角色信息

(。・∀・)ノ゙嗨 大家好,这里是池鱼

xiaoyuan_____的博客 2420

hdu 4819(裸二维线段树)

树套树,这里查询方块的最大值+最小值/2,并在x,y处更新它 #include using namespace std; typedef long long ll; typedef unsigned long long ull; #define clr(x,y) memset(x,y,sizeof x) #define INF 0x3f3f3f3f const int maxn = 800

Everything can be done! 447

AI落地困局与破局者FDE:从技术神话到价值实干的战略转型

AI落地困局与破局者FDE:从技术神话到价值实干的战略转型 当前AI企业级应用面临三大核心挑战:业务场景深度非标化、技术落地"最后一公里"困局、以及市场竞争焦点转向实用价值。前线部署工程师(FDE)作为破局关键,通过技术-业务-产品三维交汇的复合能力,将AI从实验室推向生产环境。FDE不仅是技术架构师,更是业务价值挖掘机和产品进化传感器,通过"碎石路-高速公路"双循环模式,将定制化需求沉淀为可复用的平台能力。这种模式颠覆了传统SaaS的销售逻辑,形成基于价值的J型增长

随笔记录-分享&记忆 3993

OSG三维渲染引擎编程学习之一:“第一章:OSG介绍” 之 “1.1 OSG简介”

第一章:OSG介绍; 1.1 OSG简介。

LuckyHanMo的博客 3222

二维线段树——区间最值系列

最近这几天学习了一下二维线段树,二维线段树主要有两种写法,四分树和树套树,暂时还没写过四分树,因为这个东西确实不常用,而且不好写也不好调。 树套树的写法思路其实不难,首先我们知道,我们通常的线段树的操作都是在线段上进行的,即一维的,当推广到二维上,即矩阵时,我们就把它叫做二维线段树。 二维线段树其实就是我们再操作时先找到对应x轴的区间(即第一维),之后再找到对应y轴的区间(即第二维),进行相...

mumei的博客 2854

蓝牙调试抓包工具--nRF Connect移动端 使用详细总结

摘要: nRF Connect移动端是一款功能全面的蓝牙低功耗(BLE)调试工具,支持设备扫描、多设备连接、服务/特征值查看及数据读写操作。核心功能包括实时数据通信(读取/写入/通知)、设备固件更新(DFU)以及高级工具如自动化测试和信号分析。兼容Android 4.3+和iOS设备,适用于开发调试(如ESP32/nRF52)、设备管理和数据分析。需注意设备兼容性问题(如旧安卓设备可能需关闭连续扫描),并确保数据类型匹配。配套工具链包括nRF Toolbox和nRF Connect SDK,是BLE开发的必

AIoT深度探索者 | 嵌入式系统架构师 深耕物联网(IoT)与人工智能(AI)融合技术,聚焦​​边缘计算、图像开发、低功耗通信协议​​,致力于智能硬件,关注我获取最新技术文章信息与海量资源~ 2382

二维线段树

维护一个矩阵,实现以下几个需求: ①:①:①:单点修改,区间查最值 ②:②:②:区间加,区间查和 ③:③:③:区间修改(递增),区间查最值 二维线段树本质上是树套树 因此无法实现 pushdownpushdownpushdown,用标记永久化替代 暂时无法满足任意模式的区间修改,也可能是我太菜了 注意修改后的 mergemergemerge,只针对所修改区间进行 mergemergemerge 即...

Scar_Halo 2085

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

hdoj 4819 Mosaic 【二维线段树 单点更新 区间查询】

题目链接:hdoj 4819 MosaicMosaicTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others) Total Submission(s): 1394 Accepted Submission(s): 601Problem Description The God o

世界很大 734

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

HDU 4819:单点更新,区间查询的二维线段树

我越来越觉得之前自己的代码写的就跟shi一样…… 题意很简单,矩阵中指定一个方形

暗黑ZX Cyberwind 763

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

二维线段树(模板)+HDU 4819

好久没有研究数据结构了,今天看到了一个二位ST表的题目,心里突然就想到了二位线段树,于是决定写写,后来发现坑还是很深的……         首先,我们很容易想到的方法是对于二维的,把原本的一维二叉线段树,变成一个二维的四叉线段树。这个的话更容易理解,也貌似很好写很短很漂亮,但是当然了,有很大的缺点就是速度很慢。我试过写了一个发现 HDU 4819 直接tle了,然后非常愤怒的放弃了这种方法,当然可能是我写错了。这里关于这种方式,我给一个链接,这里面配合了很多图片,讲得很好, 点击此处打开链接 但是代码风格和

alpc_qleonardo 970

HDU4819:Mosaic(二维线段树简单模板,树套树,单独修改,区间查询)

二维线段树模板题之一

蒲公英殇的博客 371

HDU 4819 Mosaic(二维线段树)

Mosaic Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others) Total Submission(s): 2691    Accepted Submission(s): 1183 Problem Description The God of sheep decides t...

GYH0730的博客 329

HDU 4819 Mosaic(二维线段树单点更新+区间查询+自己的写法模板)

The God of sheep decides to pixelate some pictures (i.e., change them into pictures with mosaic). Here's how he is gonna make it: for each picture, he divides the picture into n x n cells, where each cell is assigned a color value. Then he chooses a cell,

HJY 514

HDU 4819 Mosaic(二维线段树区间查询+单点更新模板)

The God of sheep decides to pixelate some pictures (i.e., change them into pictures with mosaic). Here's how he is gonna make it: for each picture, he divides the picture into n x n cells, where each cell is assigned a color value. Then he chooses a cell,

HJY 700

HDU 4819 Mosaic (二维线段树)

题意:            二维线段树,查询区间最大最小值,修改单点。 思路:            树套树,树和树间各写各的操作,注意conbine(自下而上的结合)和trans(自上而下的连接)即可。 代码: #include using namespace std; #define ls l,mid,rt*2,id #define rs mid+1,r,rt*2+1,id #d

DT2131 408

Hdu4819 Mosaic 二维线段树维护区间最值+单点更新

Mosaic Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others) Total Submission(s): 2077    Accepted Submission(s): 927 Problem Description The God of sheep

kyoma的博客 508

树套树-线段树套线段树

线段树套线段树简单应用。

ZigZagK的博客 4825

HDU - 4819Mosaic (二维线段树)

最终板子(单点修改+区间查询最值/矩阵和)别用结构体写了,又乱空间复杂度又高…板子题没啥好说的,维护最值就行。注意线段树开4倍空间!

qq_53398102的博客 202

NOI数据结构:二维线段树

二维线段树专题 二维线段树专题_wangheng-优快云博客_二维线段树 二维线段树 - 英雄哪里出来 - C++博客 UVA 11297 线段树套线段树(二维线段树)_园荐_博客园 浅谈二维线段树 浅谈二维线段树 - TRTTG - 博客园 POJ 2155 Matrix (二维线段树) POJ 2155 Matrix (二维线段树)_每一次AC都是一种感动-优快云博客 [luogu3397]地毯(二维线段树组) [luogu3397]地毯(二维线段树组)_fl_334正

青少年趣味编程 467
上一篇: poj 2887 块状数组/线段树
下一篇: poj 2155 二维树状数组/区间更新单点查询
HuanTongH
博客等级 码龄12年 7粉丝 110原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值