UVA 11992 - Fast Matrix Operations

使用PackStack工具自动化部署OpenStack 搭建 OpenStack 环境,每个组件的安装和配置都需要熟悉其特定的依赖关系、参数设置等,对于初学者来说容易出错。PackStack 工具通过集成一系列脚本和配置文件,便于快速搭建OpenStack练习环境。CPU:支持 Intel VT - x 或 AMD - V 硬件虚拟化技术,并且要在 BIOS 里开启此功能。内存:16GB以上存储:200GB以上可用空间(2)VMware WorkStation16.0以上版本(3)远程连接工具(如Xshell、MobaXterm) 阅读详情

题目链接:

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=501&page=show_problem&problem=3143

解题思路:

题目大意:给你一个矩阵,然后有3种操作:

1 x1 y1 x2 y2 val是将矩阵x1 y1 x2 y2的区间内的值全部增加val

2 x1 y1 x2 y2 val是将矩阵x1 y1 x2 y2的区间内的值全部设置为val

3 x1 y1 x2 y2 求出x1 y1 x2 y2的区间内的和,最大值,最小值。

矩阵不超过20行,矩阵元素却可能达到1000000个,可以想到每行建一颗线段树,则本题转为一维问题。

本题有两个操作,add和set,因此需要两个标记add和setv,含义同前。规定同时有两个标记时,表示先执行set再执行add,传递代码如下:

void pushdown(int id){
    if(tree[id].l >= tree[id].r)
        return;
    if(tree[id].setv){
        tree[id<<1].setv = tree[id<<1|1].setv = tree[id].setv;
        tree[id<<1].minn = tree[id<<1|1].minn = tree[id].setv;
        tree[id<<1].maxn = tree[id<<1|1].maxn = tree[id].setv;
        tree[id<<1].add = tree[id<<1|1].add = 0;
        tree[id<<1].sum = (tree[id<<1].r-tree[id<<1].l+1)*tree[id].setv;
        tree[id<<1|1].sum = (tree[id<<1|1].r-tree[id<<1|1].l+1)*tree[id].setv;
        tree[id].setv = 0;
    }
    if(tree[id].add){
        int tmp = tree[id].add;
        tree[id<<1].add += tmp;tree[id<<1|1].add += tmp;
        tree[id<<1].minn += tmp;tree[id<<1|1].minn += tmp;
        tree[id<<1].maxn +=tmp;tree[id<<1|1].maxn += tmp;
        tree[id<<1].sum += (tree[id<<1].r-tree[id<<1].l+1)*tmp;
        tree[id<<1|1].sum += (tree[id<<1|1].r - tree[id<<1|1].l+1)*tmp;
        tree[id].add = 0;
    }
}

AC代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#define INF 0xfffffff
using namespace std;

const int N = 1000010;
struct node{
    int l,r;
    int minn,maxn,sum;
    int add,setv;
}tree[N<<2];

int anssum,ansmin,ansmax;

void maintain(int id){
    if(tree[id].l >= tree[id].r)
        return ;
    tree[id].maxn = max(tree[id<<1].maxn,tree[id<<1|1].maxn);
    tree[id].minn = min(tree[id<<1].minn,tree[id<<1|1].minn);
    tree[id].sum  = tree[id<<1].sum + tree[id<<1|1].sum;
}

void build(int id,int l,int r){//id:index
    tree[id].l = l;
    tree[id].r = r;
    tree[id].add = 0;
    tree[id].setv = 0;
    if(l == r){
        tree[id].sum = tree[id].minn = tree[id].maxn = 0;
        return;
    }
    int mid = (l+r)>>1;
    build(id<<1,l,mid);
    build(id<<1|1,mid+1,r);
    maintain(id);
}

void pushdown(int id){
    if(tree[id].l >= tree[id].r)
        return;
    if(tree[id].setv){
        tree[id<<1].setv = tree[id<<1|1].setv = tree[id].setv;
        tree[id<<1].minn = tree[id<<1|1].minn = tree[id].setv;
        tree[id<<1].maxn = tree[id<<1|1].maxn = tree[id].setv;
        tree[id<<1].add = tree[id<<1|1].add = 0;
        tree[id<<1].sum = (tree[id<<1].r-tree[id<<1].l+1)*tree[id].setv;
        tree[id<<1|1].sum = (tree[id<<1|1].r-tree[id<<1|1].l+1)*tree[id].setv;
        tree[id].setv = 0;
    }
    if(tree[id].add){
        int tmp = tree[id].add;
        tree[id<<1].add += tmp;tree[id<<1|1].add += tmp;
        tree[id<<1].minn += tmp;tree[id<<1|1].minn += tmp;
        tree[id<<1].maxn +=tmp;tree[id<<1|1].maxn += tmp;
        tree[id<<1].sum += (tree[id<<1].r-tree[id<<1].l+1)*tmp;
        tree[id<<1|1].sum += (tree[id<<1|1].r - tree[id<<1|1].l+1)*tmp;
        tree[id].add = 0;
    }
}

void updateSet(int id,int l,int r,int val){
    if(tree[id].l >= l && tree[id].r <= r){
        tree[id].setv = val;
        tree[id].minn = val;
        tree[id].maxn = val;
        tree[id].add = 0;
        tree[id].sum = (tree[id].r-tree[id].l+1)*val;
        return;
    }
    pushdown(id);
    int mid = (tree[id].l+tree[id].r)>>1;
    if(l <= mid)
        updateSet(id<<1,l,r,val);
    if(mid < r)
        updateSet((id<<1)+1,l,r,val);
    maintain(id);
}

void updateAdd(int id,int l,int r,int val){
    if(tree[id].l >= l && tree[id].r <= r){
        tree[id].add += val;
        tree[id].minn += val;
        tree[id].maxn += val;
        tree[id].sum += (tree[id].r-tree[id].l+1)*val;
        return;
    }
    pushdown(id);
    int mid = (tree[id].l+tree[id].r)>>1;
    if(l <= mid)
        updateAdd(id<<1,l,r,val);
    if(mid < r)
        updateAdd((id<<1)+1,l,r,val);
    maintain(id);
}

void query(int id,int l,int r){
     if(tree[id].l >= l && tree[id].r <= r){
        anssum += tree[id].sum;
        ansmin = min(ansmin,tree[id].minn);
        ansmax = max(ansmax,tree[id].maxn);
        return;
    }
    pushdown(id);
    int mid = (tree[id].l+tree[id].r)>>1;
    if(l <= mid)
        query(id<<1,l,r);
    if(mid < r)
        query(id<<1|1,l,r);
    maintain(id);
}

int main(){
    int r,c,m;
    while(~scanf("%d%d%d",&r,&c,&m)){
        build(1,1,r*c);
        int op,x1,x2,y1,y2,val;
        while(m--){
            scanf("%d",&op);
            if(op == 1){
                scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&val);
                for(int i = x1; i <= x2; i++)
                    updateAdd(1,(i-1)*c+y1,(i-1)*c+y2,val);
            }
            else if(op == 2){
                scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&val);
                for(int i = x1; i <= x2; i++)
                    updateSet(1,(i-1)*c+y1,(i-1)*c+y2,val);
            }
            else{
                scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
                anssum = 0;ansmin = INF;ansmax = -INF;
                for(int i = x1; i <= x2; i++)
                    query(1,(i-1)*c+y1,(i-1)*c+y2);
                printf("%d %d %d\n",anssum,ansmin,ansmax);
            }
        }
    }
    return 0;
}


/*
4 4 8
1 1 2 4 4 5
3 2 1 4 4
1 1 1 3 4 2
3 1 2 4 4
3 1 1 3 4
2 2 1 4 4 2
3 1 2 4 4
1 1 1 4 3 3
*/


保姆级教程:Windows下用GDC-Client下载TCGA数据,从环境变量配置到成功下载 本文提供Windows平台下使用GDC-Client下载TCGA数据的完整教程,从环境变量配置到成功下载。详细介绍了GDC-Client工具的安装、系统环境变量设置、配置文件优化以及数据下载实战技巧,帮助生物信息学研究者高效获取TCGA数据库中的癌症基因组数据。 阅读详情

相关推荐

国内优秀MES开源框架

一套springboot 开源框架 代码标准规范化。 界面展示 演示地址 http://wangziyangmes.pzzd.xyz 用户名admin 密码123 系统管理 工艺管理 计划管理 物料管理 *用户管理* *工艺路线管理* 工单下达...

q707231019的博客 2万+

UVA 11992

7

大咸鱼。。。 517

将AAL图谱对应到Yeo7大网络中【原理,代码分析】

本文介绍了将AAL2图谱映射到Yeo7大功能网络的方法。通过整合皮层(Yeo2011)、小脑(Buckner2011)和纹状体(Choi2012)三个区域的功能网络图谱,采用投票机制确定每个AAL区域的网络归属。具体步骤包括:1)统计每个AAL区域体素在各网络图谱中的分布;2)选择体素数量最多的网络作为该区域的最终标签。该方法实现了从解剖结构到功能网络的映射,可获得120个AAL区域对应的7大功能网络标签。

yes666666的博客 2247

uva11992 Fast Matrix Operations (线段树)

题目:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18697 题意:给定N*M的矩阵,初始值为0。有三种操作①将x1~x2行的y1~y2列的值加v(v>0)②将x1~x2行的y1~y2列的值改为v(v>0)③查询x1~x2行的y1~y2列里面的所有值的和,以及其中的最小值和最大值。(N 分析:由于N 开始的版

w20810的专栏 505

UniApp 与 Taro 深度解析:如何根据项目需求选择最佳跨平台框架?

本文深度对比了UniApp和Taro两大主流跨平台开发框架。UniApp基于Vue生态,提供开箱即用的高效开发体验,尤其适合快速覆盖多端小程序;Taro则根植React范式,架构灵活,便于与现有React生态集成,更适合对性能和原生体验有高要求的复杂项目。文章结合团队技术栈、项目类型及性能需求,为开发者提供了清晰的选型指南。

snow3的博客 210

对单周期 RISC-V 处理器进行扩展

对单周期 RISC-V 处理器进行扩展

xiaoxian666的博客 1488

UVA11992(线段树)

题目 题意 road命令连接第A坐标和第B坐标的点。而line则是查看纵坐标C拉出的扫描线过几个联通块,要求求联通块中的数量和是多少。(具体的可以查看原题) 题解 其实是线段树一个简单的模拟,即并查集找联通块和联通块中点的数量,然后每次更新的时候,删除A点和B点的信息,重新建立A点和B点连接后的信息就行了。 #include<iostream> #include<cstring...

GenmCai 401

生成式深度学习(第二版)-第一章-Conda环境下TensorFlow和Keras的安装和配置

按照书籍中的代码运行提示,需要配置Docker。个人的机器上正好有 conda4.14.0,索性就在本地环境进行配置。

GarryWang1248的博客 400

UVA 11992 线段树将矩阵转化为一维数组

UVA11992  区间求和,最大值,最小值 题意: r行c列的全0矩阵   有三种操作 1 x1 y1 x2 y2 v子矩阵(x1,y1,x2,y2)所有元素增加v               2 x1 y1 x2 y2 v子矩阵(x1,y1,x2,y2)所有元素设为v               3 x1 y1 x2 y2 查询子矩阵元素的和、最小值、最大值 题解: 由于r&lt;...

c___c18的博客 260

【WRF-DART第一期】WRF/DART概述

【WRF-DART第一期】WRF/DART概述

WW、forever的博客 115

《网络安全自学教程》- OSI七层模型分层及作用,数据封装与解封过程,数据传输过程。

OSI分哪七层,每层的作用是什么,解释数据在七层模型中是怎样传输的,封包和解封过程,数据包在每一层是怎么封装和解封的。

wangyuxiang946的博客 1万+

UVa 11992 Fast Matrix Operations 线段树

UVa 11992 Fast Matrix Operations 题目大意:有一个r行c列的全0矩阵,支持

poursoul 786

基于强化学习的多无人机路径规划

我们使用了Dueling Double Deep Q-Network(DDDQN)算法来训练智能体,这个算法在深度Q学习算法的基础上进行了升级,具有更快的收敛速度和更好的性能。本文提出了一种基于强化学习的算法,实现了多无人机路径规划,并提供相应的MATLAB代码。通过基于强化学习的多无人机路径规划算法,我们能够高效地解决复杂环境下的任务需求,并在实际应用中取得了良好的效果。首先,我们定义了状态空间和动作空间。实验结果表明,我们的方法能够有效地解决多无人机路径规划问题,提高了任务完成的效率和准确率。

DjjPython的博客 826

UVA 11992 Fast Matrix Operations

题目链接:UVA 11992 Fast Matrix Operations 分析: 其实这题只用把矩阵完全看成一维的一排数,开一个数组建一个线段树,就行了。然而我却傻傻的每行开了一个线段树,代码有点丑,不要在意。 主要是set操作和Add操作之间的关系要搞清楚。 因为始终是先处理set再处理add,所以set标记传递的时候必须把add标记改为0(代码中有注释),这里很容易忘掉,

INCINCIBLE的博客 499

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

UVA11992 Fast Matrix Operations

线段树 区间增加+区间覆盖

a free man 631

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

UVA 11992 Fast Matrix Operations

每一行都建一个线段树。。。。 Fast Matrix Operations There is a matrix containing at most 106 elements divided into r rows and c columns. Each element has a location (x,y) where 1 1 x1 y1 x2 y2 v

码代码的猿猿 1239

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Fast Matrix Operations UVA - 11992

文章目录 原版刘汝佳的代码有很多maintain语句,个人感觉这样很不符合习惯,所以做出了修改,更符合我的习惯 1: 只保留一个update时的maintain语句 2:时刻记着延迟标记只是延迟往下的标记,并不延迟节点本身,时刻修改,当延迟标记下到某个地方,它的值就应该被修改 // UVa11992 Fast Matrix Operations(更易读、更具一般性的版本) // Rujia Liu...

海边拾贝,沧海一粟 221

uva 11992 Fast Matrix Operations

题目链接: uva 11992 Fast Matrix Operations 题目大意: 你有r∗c(r<=20,r∗c<=106)r*c(r<=20,r*c<=10^6)r∗c(r<=20,r∗c<=106)的数字矩阵,每次可以将(x1,y1)(x2,y2)(x_1,y_1)(x_2,y_2)(x1​,y1​)(x2​,y2​)之间的数字加一个值,或将(x1,y1)(x2,y2)(x_1,y_1)(x_2,y_2)(x1​,y1​)(x2​,y2​)之间的数字改为一个值

lycccccccc的博客 184

UVA - 11992——Fast Matrix Operations(线段树)

题目链接:https://cn.vjudge.net/problem/UVA-11992 思路:把二维当成一维,每次查询或者操作x1,y1,x2,y3区域的时候都分成处理x2-x1+1个小段,每一段处理y1~y2这个区间。 #include<string.h> #include<stdio.h> #include<algorithm> using name...

creator平 227

Uva 11992 Fast Matrix Operations

一堆线段树打标记

我要吃熊猫 382

UVA 11992 Fast Matrix Operations 线段树

UVA 11992有一个r行c列的全0矩阵,查询个数是m,支持一下3种操作,op x1 y1 x2 y2 v,op=1时子矩阵全部加v,op=2时子矩阵全部设为v,op=3时求子矩阵的元素和以及最小值,最大值。因为题目说了矩阵不超过20行且元素总和不超过1e6,可以把二维化一维,x1 y1到x1 y2可以换成 (x1-1)*c+y1到 (x1-1)*c+y2接下来就是套用刘汝佳的模板了,因为一个细...

ccsu_cat 319

UVA 11992 - Fast Matrix Operations(线段树)

UVA 11992 - Fast Matrix Operations 题目链接 题意:给定一个矩阵,3种操作,在一个矩阵中添加值a,设置值a,查询和 思路:由于最多20列,所以完全可以当作20个线段树来做,然后线段树是区间修改区间查询,利用延迟操作,开两个延迟值一个存放set操作,一个存放add操作 代码: #include #include #include

Remilia's 1589

【UVa11992】Fast Matrix Operations 快速矩阵操作

题目描述 给定一个r*c(r<=20,r*c<=1e6)的矩阵,其元素都是0,现在对其子矩阵进行操作。 1 x1 y1 x2 y2 val 表示将(x1,y1,x2,y2)(x1<=x2,y1<=y2)子矩阵中的所有元素加val; 2x1 y1 x2 y2 val 表示将(x1,y1,x2,y2)(x1<=x2,y1<=y2)子矩阵中的所有元素...

anweiyun4308的博客 196

uva11992 Fast Matrix Operations 线段树打标记

现在想起来自己好像从来都没有写过线段树lazy tag呢,唉真是惭愧。现在老师开始讲线段树了,我就被要求滚去写线段树啦。。        这道题就是区间都加上一个值;区间都变为一个值;求区间和,最大值,最小值。其中行数 AC代码如下: #include #include #include #define N 500005 #define inf 1000000000 using namesp

lych的博客 606

uva11992 Fast Matrix Operations

思路:看似一个二维矩阵值的更新,其实就是换成多条线段更新,线段树。 总共有3种操作: 1. 1 x1 y1 x2 y3 val(在满足(x,y)的点上+val) 2. 2 x1 y1 x2 y2 val(把满足条件的点清空为val) 3. 3 x1 y1 x2 y3 查询区间值 sum min max。 因为有延迟标记,所以每次要down和up下,二维在down的时候还要先考虑区间是否被

KIJamesQi的博客 520

Fast Matrix Operations UVA 11992-线段树

这个题属于线段树的一个入门题,对线段树了解之后可以用这个题练一练 题意: 有一个初始状态全为0的矩阵,一共有三个操作 1x1 y1 x2 y2 v:子矩阵(x1,y1,x2,y2)所有元素增加v add 2x1 y1 x2 y2 v:子矩阵(x1,y1,x2,y2)所有元素设为v ...

P19777的博客 222
上一篇: hihoCoder 1069 最近公共祖先·三
下一篇: hihoCoder 1080 更为复杂的买卖房屋姿势(区间更新)
yphacker
博客等级 码龄12年 199粉丝 540原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值