HDU2888

【驭风计划 算法训练营】周测4:习题11-4、8-4、12-4 给出 nn 个非负整数 x1,x2,⋯,xnx1,x2,⋯,xn,有 qq 个询问,第 jj 个询问给出一个非负整数 yjyj,求其中,xor 表示按位异或运算。 阅读详情

Paul draw a big m*n matrix A last month, whose entries Ai,j are all integer numbers ( 1 <= i <= m, 1 <= j <= n ). Now he selects some sub-matrices, hoping to find the maximum number. Then he finds that there may be more than one maximum number, he also wants to know the number of them. But soon he find that it is too complex, so he changes his mind, he just want to know whether there is a maximum at the four corners of the sub-matrix, he calls this “Check corners”. It’s a boring job when selecting too many sub-matrices, so he asks you for help. (For the “Check corners” part: If the sub-matrix has only one row or column just check the two endpoints. If the sub-matrix has only one entry just output “yes”.)
Input
There are multiple test cases.

For each test case, the first line contains two integers m, n (1 <= m, n <= 300), which is the size of the row and column of the matrix, respectively. The next m lines with n integers each gives the elements of the matrix which fit in non-negative 32-bit integer.

The next line contains a single integer Q (1 <= Q <= 1,000,000), the number of queries. The next Q lines give one query on each line, with four integers r1, c1, r2, c2 (1 <= r1 <= r2 <= m, 1 <= c1 <= c2 <= n), which are the indices of the upper-left corner and lower-right corner of the sub-matrix in question.
Output
For each test case, print Q lines with two numbers on each line, the required maximum integer and the result of the “Check corners” using “yes” or “no”. Separate the two parts with a single space.
Sample Input
4 4
4 4 10 7
2 13 9 11
5 7 8 20
13 20 8 2
4
1 1 4 4
1 1 3 3
1 3 3 4
1 1 1 1
Sample Output
20 no
13 no
20 yes
4 yes

还是二维rmq板子题…

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int mm[600];
int tu[305][305];
int dpmax[305][305][9][9];
void rmq(int n, int m)
{
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            dpmax[i][j][0][0] = tu[i][j];
    for (int ii = 0; ii <= mm[n]; ii++)
        for (int jj = 0; jj <= mm[m]; jj++)
            if (ii + jj)
                for (int i = 1; i + (1 << ii) - 1 <= n; i++)
                    for (int j = 1; j + (1 << jj) - 1 <= m; j++)
                    {
                        if (ii)
                        {
                        //  dpmin[i][j][ii][jj] = min(dpmin[i][j][ii - 1][jj], dpmin[i + (1 << (ii - 1))][j][ii - 1][jj]);
                            dpmax[i][j][ii][jj] = max(dpmax[i][j][ii - 1][jj], dpmax[i + (1 << (ii - 1))][j][ii - 1][jj]);
                        }
                        else
                        {
                        //  dpmin[i][j][ii][jj] = min(dpmin[i][j][ii][jj - 1], dpmin[i][j + (1 << (jj - 1))][ii][jj - 1]);
                            dpmax[i][j][ii][jj] = max(dpmax[i][j][ii][jj - 1], dpmax[i][j + (1 << (jj - 1))][ii][jj - 1]);
                        }
                    }
}
/*int chaxunxiao(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 min(min(dpmin[x1][y1][k1][k2], dpmin[x1][y2][k1][k2]), min(dpmin[x2][y1][k1][k2], dpmin[x2][y2][k1][k2]));
}*/
int chaxunda(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(dpmax[x1][y1][k1][k2], dpmax[x1][y2][k1][k2]), max(dpmax[x2][y1][k1][k2], dpmax[x2][y2][k1][k2]));
}
int main()
{
    int n, m;
        mm[0] = -1;
    for (int i = 1; i <= 500; i++)
        mm[i] = ((i&(i - 1)) == 0) ? mm[i - 1] + 1 : mm[i - 1];
    while(cin >> n >> m )
{
    memset(dpmax,0,sizeof(dpmax));
    memset(tu,0,sizeof(tu));
    for (int a = 1; a <= n; a++)
    {
        for (int b = 1; b <= m; b++)
        {
            scanf("%d", &tu[a][b]);
        }
    }
    rmq(n,m);
    int q, w,g,e,r;
    cin >> g;
    for (int a = 1; a <= g; a++)
    {
        scanf("%d%d%d%d", &q, &w,&e,&r);
        if(q>e)swap(q,e);
        if(w>r)swap(w,r);
        int ty = chaxunda(q, w, e, r);
        printf("%d ", ty);
        if (ty == tu[q][w] || ty == tu[e][r] || ty == tu[q][r] || ty == tu[e][w])
        {
            printf("yes\n");
        }
        else printf("no\n");
    }}
    return 0;
}
CODESYS做Modbus TCP主站踩坑记:从IP配置到数据映射的完整避坑指南 本文详细记录了在CODESYS中配置Modbus TCP主站的全过程,从IP配置到数据映射的常见问题及解决方案。重点解析了网络适配器选择、Slave ID误解、地址偏移陷阱等关键问题,并提供了实用的调试技巧和性能优化建议,帮助工业通信开发者高效避坑。 阅读详情

相关推荐

深入探究贝叶斯网络(Bayesian Network):从基础原理到实际应用

贝叶斯网络,也称为信念网络或有向无环图模型,是一种概率图模型。它使用有向无环图(DAG)来表示随机变量之间的条件依赖关系。每个节点代表一个随机变量,边表示变量之间的条件依赖关系。贝叶斯网络作为一种强大的工具,通过结合概率论和图论,为复杂系统建模和推理提供了有效手段。无论是在医学诊断、故障检测还是自然语言处理等领域,它都展示了巨大的潜力。然而,其计算复杂度高、结构学习困难等挑战也需要我们在实际应用中不断优化算法和技术。希望通过本文,你能对贝叶斯网络有更深入的理解,并能够在实际项目中灵活应用这一强大工具。

qq_28791753的博客 5979

HDU2888(二维RMQ)

题意:给一个矩阵,然后给Q个询问,每个询问有四个数,分别代表询问的子矩阵的左上角和右下角,然后找出子矩阵的最大值输出,然后再把这个值与 子矩阵的四个角的值比较,如果有至少一个等于这个最大值就输出“yes”,否则输出“no”。 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2888 这是一道二维的RMQ区间最值问题,其实和一维的核心思想都是倍增思

weishengmingerfendou的专栏 484

Orale EBS R12 AP应付模块 发票导入接口(Interface)

ap_interface_groups_s.nextval; ap_invoices_interface_s.nextval; ap_invoice_lines_interface_s.nextval; SELECT * FROM ap_invoices_interface ih; SELECT * FROM ap_invoice_lines_interface il; SELECT * FROM...

qq_41206741的博客 3331

HDU2888(二维RMQ/二维线段树 模板)

Check Corners Time Limit: 2000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3572    Accepted Submission(s): 1282   Problem Description Paul draw a big m*...

Dog_dream的博客 390

深入解析数据通信中的码元速率与比特率:从基础到实战应用

本文深入解析了数据通信中的核心概念码元速率与比特率,通过生动的比喻和公式(比特率=波特率×log₂(M))揭示其本质关系。文章结合BPSK、QPSK、16QAM等调制技术,剖析了从4G/5G到LoRa等实战场景中如何权衡速率、距离与可靠性,并提供了软考真题解析与系统设计建议,帮助读者从理论到应用全面掌握数据速率优化。

weixin_29324877的博客 221

Win11 系统下 VisualStudio2022 配置点云库 PCL1.11.1

安装完成之后打开文件夹E:\PCL 1.11.1\3rdParty\OpenNI2双击 并选择路径 (E:\PCL 1.11.1\3rdParty\OpenNI2) 安装即可全部安装完成之后,将pcl-1.11.1-pdb-msvc2019-win64.zip解压后的 .pdb文件拷贝到(E:\PCL 1.11.1\bin)中设置环境变量:到此,环境变量配置完成。

qq_53545309的博客 1145

HDU-2888——Check Corners(二维RMQ)

题意:给你一个N*M的矩阵,询问一个子矩阵的最大值,并且判断子矩阵的四边是不是等于子矩阵的最大值 分析:这是一道显然的RMQ问题,没啥好说的,注意细节! #include #include #include #include #include #include #include #include #include #include #include #include #

shengtao96的专栏 552

Eclipse 打开报 `An error has occurred. See the log null` 错误及解决方法

摘要:Eclipse启动时报错"An error has occurred. See the log null"通常是由于非正常关闭导致org.eclipse.osgi配置文件损坏所致。解决方法包括:1)以管理员身份启动(适用于权限问题);2)删除损坏的org.eclipse.osgi文件夹;3)最有效的方法是换目录重新安装Eclipse。建议规范使用开发工具、及时备份项目,避免非正常关闭操作,以维护稳定的开发环境。该问题虽小但提醒我们开发工具的日常维护同样重要。

博客 1171

HDU - 2888 Check Corners 【RMQ(二维线段树 / ST)】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2888 第一种方法是二维线段树,注意的地方在代码注释的部分。第二种方法是 ST算法,在后面。 #include &lt;iostream&gt; #include &lt;cstdlib&gt; #include &lt;cstdio&gt; #include &lt;cstring&gt; #i...

Y390d的博客 217

华为OD机试真题 新系统2026-04-08 Python&JS 实现【配置操作失败数量统计】

模拟一个系统的命令行配置,包含添加、修改、删除三项操作,详情如下: 添加操作命令:add_rulerule_id=1rule_index = 18 修改操作命令: mod_rule rule_id= 1rule_index = 100 删除操作命令:del_rulerule_id=1

MISAYAONE的博客 601

27、超声成像技术与原理全面解析

本博客全面解析了超声成像技术与原理,涵盖声学材料特性、超声成像系统的基本概念与组成、关键技术如多普勒和聚焦技术、超声换能器的设计与原理、图像处理方法、系统校准与质量控制,以及超声成像的应用领域和发展趋势。旨在为医学诊断、工业检测和海洋声学等领域的研究人员和工程师提供深入的技术参考和指导。

z2a3b4c5d的博客 509

hdu 2888 Check Corners(RMQ)

题目链接:hdu 2888 Check Corners 题目大意:给定一个矩阵,每次查询矩阵中的最大值,并且判断该最大值是否在所查询的角落上。 解题思路:一开始用线段树,一维RMQ都超时了,然后换成了二维的RMQ,结果MLE,dp数组换成9∗9就过了。 #include #include #include using namespace std; const int maxn

不慌不忙、不急不躁 1114

AD快速上手笔记

本文详细介绍了使用Altium Designer从零创建PCB项目全流程:新建工程、绘制原理图(元件放置、连线、电源端口)、编译检查、生成PCB、布局布线(含铺铜)、DRC检查及输出Gerber与钻孔文件。重点强调了库选择、参数修改、层切换、铺铜设置和生产文件导出规范,确保设计无误,便于顺利下单生产。

qq_53529450的博客 54

HDU 2888 Check Corners(简单二维RMQ)

HDU 2888 Check Corners(简单二维RMQ) 分析:基本的二维RMQ应用. 注意题目中存的矩阵是无符号整数的矩阵. AC代码:3625ms #include #include #include using namespace std; const int MAXN =305; unsigned int val[MAXN][MAXN]; unsigned int

code 1163

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

hdu2888(二维RMQ)

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2888 之前可能学了假的二维RMQ,跑了9000多ms。。。。。。 1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> ...

weixin_30897233的博客 88

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

HDU2888二维RMQ

HDU2888二维RMQ dp[row][col][i][j] 表示[row,row+2^i-1]x[col,col+2^j-1] 二维区间内的最小值 这是RMQ-ST算法的核心: 倍增思想 == min( [row,row+ 2^(i-1)-1]x[col,col+2...

chenwang9876的博客 173

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

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

【HDU 2888】RMQ

1.题目链接。题目大意,给定一个矩阵,然后Q组询问,询问是(x,y,x1,y1).问以这两个点组成的子矩阵里面的最大值是不是在四个角上。 2.RMQ寻找最大值,然后判断一下是不是在角上即可。但是注意一下这里的内存已经是很有限了,所以需要严格的注意数组大小很容易MLE。 #include<iostream> #include <string.h> #include &l...

YG爱木木 292

HDU2888 Check Corners

二维RMQ问题 题意是输入一个矩阵,然后

AC_Gibson的专栏 661

HDU-OJ-2888 Check Corners

Check Corners Time Limit: 2000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Paul draw a big m*n matrix A last month, whose entries Ai,j are all

JSure的代码库 1068

HDU 2888 Check Corners

二维ST表

脚踏实地,仰望星空 262

HDU 2888(二维RMQ模板)

题目描述: Check Corners Time Limit: 2000/10000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3808Accepted Submission(s): 1351Pr...

又菜又爱玩 246

HDU2888 Check Corners

Description Paul draw a big m*n matrix A last month, whose entries Ai,j are all integer numbers ( 1 <= i <= m, 1 <= j <= n ). Now he selects some sub-matrices, hoping to find ...

dezhen7015的博客 148

HDU-2888(Check Corners)

题意:给定一个二维矩阵,然后有Q个询问,每个询问给出两个坐标,求以这两个坐标为左上角和右下角的矩阵内的最大值,并判断这个值是否是矩阵四个角的值。 分析:二维RMQ裸题。 代码: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> usi...

Joker & Liar的博客 286

二维RMQ hdu 2888

题目:点这里 题意:给出一个n*m的矩阵,然后又Q个询问:每个询问有x1,y1,x2,y2,x1,y1为子矩阵的左上角坐标,x2,y2为右上角的坐标。求此子矩阵中元素最大值,判断最大值是否在子矩阵四个角上,在就输出yes,否则输出no。 分析:二维RMQ直接上代码。 #include<iostream> #include<stdio.h> #incl...

acs59147的博客 174

hdu 2888 Check Corners

/* 题意:给出m,n代表给出长为m宽为n的矩阵,然后给出一个q代表查询的次数,然后q行每行给出一个 r1, c1, r2, c2 且满足(1 <= r1 <= r2 <= m, 1 <= c1 <= c2 <= n) 输出这个矩形范围内的最大值,如果最大值是四个顶点某一个的话就输出yes否则输出no */ #include #include #define Max(a,b) a>b?a:b in

编程中快乐 700

hdu-2888 Check Corners

描述 Paul draw a big m*n matrix A last month, whose entries Ai,j are all integer numbers ( 1 <= i <= m, 1 <= j <= n ). Now he selects some sub-matrices, hoping to find the maximum number. Then he finds

140142 950
上一篇: HDU3193
下一篇: codeforces 453A
NineFailure
博客等级 码龄11年 22粉丝 317原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址