poj 2019 二维RMQ

告别效率低谷:用ADS仿真手把手教你设计高回退Doherty功放(附1:2非对称案例) 本文详细解析了如何使用ADS仿真设计高回退Doherty功放,特别针对1:2非对称架构进行深入探讨。通过优化功率分配比、峰值管开启阈值等关键参数,显著提升功放在9dB回退点的效率至75%以上,适用于LTE等高PAPR信号场景。文章还提供了ADS仿真环境搭建、参数优化及工程化设计的实用技巧。 阅读详情

Cornfields
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 6169 Accepted: 3039

Description

FJ has decided to grow his own corn hybrid in order to help the cows make the best possible milk. To that end, he's looking to build the cornfield on the flattest piece of land he can find. 

FJ has, at great expense, surveyed his square farm of N x N hectares (1 <= N <= 250). Each hectare has an integer elevation (0 <= elevation <= 250) associated with it. 

FJ will present your program with the elevations and a set of K (1 <= K <= 100,000) queries of the form "in this B x B submatrix, what is the maximum and minimum elevation?". The integer B (1 <= B <= N) is the size of one edge of the square cornfield and is a constant for every inquiry. Help FJ find the best place to put his cornfield. 

Input

* Line 1: Three space-separated integers: N, B, and K. 

* Lines 2..N+1: Each line contains N space-separated integers. Line 2 represents row 1; line 3 represents row 2, etc. The first integer on each line represents column 1; the second integer represents column 2; etc. 

* Lines N+2..N+K+1: Each line contains two space-separated integers representing a query. The first integer is the top row of the query; the second integer is the left column of the query. The integers are in the range 1..N-B+1. 

Output

* Lines 1..K: A single integer per line representing the difference between the max and the min in each query. 

Sample Input

5 3 1
5 1 2 6 3
1 3 5 2 7
7 2 4 6 1
9 9 8 6 5
0 6 9 3 9
1 2

Sample Output

5


/*
poj 2019 二维RMQ
前段时间不知道poj怎么了,现在补上
二维RMQ简单,求解区间最大最小值的差
hhh-2016-02-02 19:25:50
*/

#include <functional>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <Map>
using namespace std;
typedef long long ll;
typedef long double ld;

using namespace std;
const int maxn = 255;
int dp[maxn][maxn][8][8];
int dp1[maxn][maxn][8][8];
int tmap[maxn][maxn];
int mm[maxn];
void iniRMQ(int n,int m)
{
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            dp[i][j][0][0] = tmap[i][j];
            dp1[i][j][0][0] = tmap[i][j];
        }
    for(int ti = 0; ti <= mm[n]; ti++)
        for(int tj = 0; tj <= mm[m]; tj++)
            if(ti+tj)
                for(int i = 1; i+(1<<ti)-1 <= n; i++)
                    for(int j = 1; j+(1<<tj)-1 <= m; j++)
                    {
                        if(ti)
                        {
                            dp[i][j][ti][tj] =
                                max(dp[i][j][ti-1][tj],dp[i+(1<<(ti-1))][j][ti-1][tj]);
                            dp1[i][j][ti][tj] =
                                min(dp1[i][j][ti-1][tj],dp1[i+(1<<(ti-1))][j][ti-1][tj]);

                        }
                        else
                        {
                            dp[i][j][ti][tj] =
                                max(dp[i][j][ti][tj-1],dp[i][j+(1<<(tj-1))][ti][tj-1]);
                            dp1[i][j][ti][tj] =
                                min(dp1[i][j][ti][tj-1],dp1[i][j+(1<<(tj-1))][ti][tj-1]);
                        }
                    }
}

int RMQ(int x1,int y1,int x2,int y2)
{
    int k1 = mm[x2-x1+1];
    int k2 = mm[y2-y1+1];
    x2 = x2 - (1<<k1) +1;
    y2 = y2 - (1<<k2) +1;
    return
        max(max(dp[x1][y1][k1][k2],dp[x1][y2][k1][k2]),
            max(dp[x2][y1][k1][k2],dp[x2][y2][k1][k2])) -
        min(min(dp1[x1][y1][k1][k2],dp1[x1][y2][k1][k2]),
            min(dp1[x2][y1][k1][k2],dp1[x2][y2][k1][k2]));
}

int main()
{
    int a,b,n,m,k;
    mm[0] = -1;
    for(int i = 1;i < 255;i++)
    {
        mm[i] = (i&(i-1)) == 0 ? mm[i-1]+1:mm[i-1];
    }
    while(scanf("%d%d%d",&n,&m,&k) != EOF)
    {
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
            {
                scanf("%d",&tmap[i][j]);
            }
        iniRMQ(n,n);
        while(k--)
        {
            scanf("%d%d",&a,&b);
            printf("%d\n",RMQ(a,b,a+m-1,b+m-1));
        }
    }
}



Flutter模块打包AAR集成Android原生项目实践 跨平台开发框架Flutter通过将UI组件渲染为原生代码实现高性能表现,其核心优势在于一套代码可同时运行在iOS和Android平台。在工程实践中,将Flutter模块打包为AAR(Android Archive)进行集成,成为混合开发的主流方案。这种方案既保留了原生项目的稳定性,又能渐进式引入Flutter的高效开发特性。通过配置MethodChannel实现原生与Dart代码通信,开发者可以灵活控制Flutter引擎生命周期,优化内存占用和渲染性能。对于电商、社交等需要快速迭代的业务场景,该方案能显著提 阅读详情

相关推荐

LabVIEW QMH模板实战:从创建到错误处理的完整指南

本文提供LabVIEW QMH模板从创建到错误处理的完整实战指南。详细解析了队列消息处理器(QMH)作为LabVIEW核心设计模式如何实现任务解耦与异步通信,涵盖事件处理循环、消息处理循环的搭建、用户事件创建、队列引用管理、消息优先级控制以及健壮的错误处理机制,帮助开发者构建稳定、可维护的复杂应用程序。

white的博客 725

每日一题----Cornfields--poj2019(附翻译和题解)

二维稀疏表

2201_75867204的博客 355

TPS5430/54302调试血泪史:从‘烫手山芋’到冒烟烧板,我的5V电源到底怎么了?

本文深入剖析了TPS5430/TPS54302 DCDC电源芯片调试中的常见问题,包括异常发热、电压漂移等,并提供了从热设计到PCB布局的全面解决方案。通过实战案例,揭示了数据手册中未明确的‘潜规则’,帮助工程师避免烧板风险,提升电源系统稳定性。

weixin_28744423的博客 501

Cornfields(二维ST表模板)

FJ has decided to grow his own corn hybrid in order to help the cows make the best possible milk. To that end, he’s looking to build the cornfield on the flattest piece of land he can find. FJ has, at...

宇宙无敌大可爱CUU的博客 1342

FPGA实现16x16点阵汉字滚动显示:Verilog代码与Quartus仿真详解

本文详细介绍了如何使用FPGA实现16x16点阵汉字滚动显示,包括Verilog代码设计、Quartus仿真及硬件连接技巧。通过字模数据存储和扫描控制逻辑,实现汉字的动态显示效果,并提供了优化建议和常见问题解决方案,适合FPGA开发者和硬件爱好者学习参考。

weixin_29172963的博客 350

可视化大屏系列(5):设备状态面板与数据分析仪表盘

在这篇文章中,我们将重点讨论如何通过智能化手段提升工地设备的管理效率与维护质量。随着智能工地系统的不断发展,设备监控与维护管理变得尤为重要。本篇将从 设备状态实时监控、自动化维护提醒、设备管理与维修记录 三个方面入手,展示如何通过 Vue3 和 ECharts 构建一个智能化的设备管理平台,实时采集和展示设备运行状态、及时生成维护提醒并记录维修历史,以提高设备的使用效率与安全性。我们还将结合实际代码示例,详细讲解如何实现这些功能,帮助你在智能工地项目中实现设备管理的智能化、数字化和自动化。

一名热衷于技术的全栈开发者,专注于前端与后端的全面技术探索。在这里,我将分享我在技术领域的学习与成长,助力更多开发者的进步。 3364

POJ 2019 Cornfields(我的水题之路——多case??TLE??)

Cornfields Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 4034   Accepted: 1933 Description FJ has decided to grow his own corn hybrid in order to help th

1125

模拟IC设计避坑:手把手教你用Cadence仿真恒定跨导轨到轨运放(附完整工艺库文件)

本文详细解析了使用Cadence仿真恒定跨导轨到轨运放的全流程,涵盖电路原理、工艺库配置、尺寸设计及仿真分析。通过1:3电流镜补偿技术实现跨导稳定,提供CSMC 0.25um工艺下的实战案例,帮助工程师规避设计陷阱,提升模拟IC设计效率。

weixin_30952535的博客 494

POJ-2019——Cornfields(二维RMQ?暴力吧!)

题意:给你一个N*N的矩阵,每一个点有一个权值,询问子矩阵中最大值与最小值的差 分析:感觉没啥好说的,这是一个显然的二维RMQ问题,把模版一套,AC!结果很奇怪的是这道题很水,暴力也可以过,真是见了鬼了! 二维ST算法 #include #include #include #include #include #include #include #include #includ

shengtao96的专栏 904

CVPR 2027 投稿规划:基于近3年录用率与截稿周期的5步时间管理法

本文为计算机视觉研究者提供CVPR 2027投稿的完整规划指南,基于近三年录用率与截稿周期数据,提出五步时间管理法。涵盖选题策略、实验设计、论文写作、同行评审到最终提交的全流程优化,特别针对CVPR日益激烈的竞争环境(2024年投稿量达11532篇,录取率仅23.6%)提供实用解决方案,帮助研究者提升投稿成功率。

weixin_34079177的博客 1143

【GPFS专题5】---IBM Spectrum Scale (GPFS) 日常运维命令大全

掌握这些命令是有效管理 GPFS 集群的基础。实际生产环境中,建议结合自动化脚本和监控系统(如 IBM Storage Insights)实现高效运维。定期备份配置、监控性能指标,并进行灾备演练,是保障数据安全和系统稳定的关键。

jundao1997的专栏 840

POJ - 2019 Cornfields 【二维线段树】

题目链接:https://vjudge.net/problem/POJ-2019 我写的这个二维线段树没什么技巧,就是直接开一个 node[cur][cure],cur代表的是x轴的一维线段树,cure代表的是y轴的一维线段树。 初始化: 先从x轴开始做线段树的操作,当x轴到达叶节点时,再对y轴做线段树的操作,x轴返回到父节点时,一样要对y轴从1到N重头做一次线段树的操作,这是初始化的过程,...

Y390d的博客 247

信捷PLC XD5系列运动控制(10轴)编程应用篇

项目PLC采用XD5-60T10-E,36DI 24DO 晶体管输出,支持10路脉冲输出功能。TMR指令定时器时基可以自己设定,这点比其他品牌PLC方便。ZRN指令我们需要上升沿指令触发。 5、变址寻址 该说不说这个变址寻址是真的强,比西门子指针、三菱的变址寄存器Z 、V都要更加灵活。 7、特殊寄存器:时钟 8、如何建立PLC通讯...............

RXXW_Dor的博客 1万+

RMQ(一维+二维)附例题 POJ 3264,POJ 2019

代码功能 众所周之,求区间最值对于ACMer来说,是必须掌握的,为此我将之贴一下,注解也比较详细,方便查阅。 这段代码能够求一段连续的数在任意区间的最值。 代码区(一维+详细说明) #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #inclu...

天际苍穹的博客 291

蓝牙模块HM-10手册

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

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Poj 2019 Cornfields【二维RMQ-------ST算法】

Cornfields Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6608   Accepted: 3234 Description FJ has decided to grow his own corn hybrid in order to help th

mengxiang000000 2015

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

【POJ 2019]二维RMQ

1.题目链接。题目大意,给定一个矩阵,k组询问,每组询问(x,y)输出以(x,y)为左上角,宽度为B的子矩阵里面最大值和最小值之差。 2.二维RMQ的裸题了,dp[i][j][a][b]代表的是当前点在(i,j)到(i+pow(2,a),j+pow(2,b))的最值。询问也是一样。模板题。 #include<iostream> #include <string.h> ...

YG爱木木 252

POJ - 2019 Cornfields 二维RMQ

题意 给出n∗n的矩阵。给出n∗n的矩阵。给出n*n的矩阵。 多次查询(x,y)为左上顶点,长度为b的子矩阵的最大值最小值差。多次查询(x,y)为左上顶点,长度为b的子矩阵的最大值最小值差。多次查询(x,y)为左上顶点,长度为b的子矩阵的最大值最小值差。 题解 二维ST表二维ST表二维ST表 给出两种二维RMQ写法给出两种二维RMQ写法给出两种二维RMQ写法 Code1Code...

Uniontake 503

poj 2019(二维RMQ)

Cornfields Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3842   Accepted: 1823 Description FJ

志当存高远 1158

POJ2019 Cornfields 二维RMQ问题

二维RMQ问题 题意是输入

AC_Gibson的专栏 638

M - POJ 2019 二维RMQ

FJ has decided to grow his own corn hybrid in order to help the cows make the best possible milk. To that end, he's looking to build the cornfield on the flattest piece of land he can find. FJ has, a...

qq_42569807的博客 278

POJ 2019 二维RMQ

题意很明显。。 二维RMQ或者二维线段树 1.二维RMQ #include #include #include #include #include using namespace std; int val[255][255]; int dpmin[255][255][8][8];//最小值 int dpmax[255][255][8][8];//最大值 void init

' 泪 添 无 言's blog 395

poj 2019 Cornfields(二维RMQ)

Cornfields Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5310   Accepted: 2613 Description FJ has decided to grow his own corn hybrid in order to help the co

WEYuLi的专栏 775

POJ - 2019(RMQ二维)

FJ has decided to grow his own corn hybrid in order to help the cows make the best possible milk. To that end, he's looking to build the cornfield on the flattest piece of land he can find.  FJ has, a...

bjfu170203101的博客 465

POJ 2019 Cornfields [二维RMQ]

二维RMQ。求一个矩阵的子矩阵各元素的最大值与最小值之差。用int会超内存,改用short。 #include #include #include #include #include using namespace std; const int maxn = 255; int n, b, k; short dpmin[maxn][maxn][10][10]; short dpm

~飞呀,飞~ 1221

POJ--2019--Cornfields【二维RMQ】

#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define PI acos(-1.0) #def

阳光照耀圣西罗 740

POJ 2019 Cornfields 二维RMQ

题目来源:POJ 2019 Cornfields 题意:求正方形二维区间最大最小值的差 思路:直接二维ST搞 试模版而已 #include #include #include using namespace std; const int maxn = 255; int dp[maxn][maxn][8][8]; int dp2[maxn][maxn][8][8]; int a[

嗯。 1104
上一篇: hdu3966 点权模板-树链部分
下一篇: poj3237 树链部分 边权模板
Tyuio28
博客等级 码龄11年 12粉丝 279原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值