http://codeforces.com/problemset/problem/777/C

题意:给一个矩阵,对于每一列定义一个子序列使得mp[i][j] >= mp[i-1][j],即如果满足这样的情况,那么序列长度+1。给出q个询问,问[l,r]的行区间内是否有一个这样的子序列。

思路:用两个数组,第一个数组row记录每一列到第i行的序列长度,第二个数组ans记录每一行到第j列最长的序列长度。然后询问的时候判断ans[r]是否有区间长度大就可以了。

5 4
1 2 3 5
3 1 3 2
4 5 2 3
5 5 3 2
4 4 3 4 1 : row[0] = 1, row[1] = 1, row[2] = 1, row[3] = 1. ans[1] = 1.
2 : row[0] = 2, row[1] = 1, row[2] = 2, row[3] = 1. ans[2] = 2.
3 : row[0] = 3, row[1] = 2, row[2] = 1, row[3] = 2. ans[3] = 3.
以此类推
 #include <bits/stdc++.h>
using namespace std;
#define N 100100
typedef long long LL;
const int INF = 0x3f3f3f3f;
vector<int> mp[N];
int ans[N], row[N];
// row维护的是每一列向上延伸能达到的长度
// ans维护的是当前这一行向上延伸能够达到的最大序列长度,由row取最优得到
// 如果ans[r] >= r - l + 1,说明这个区间长度是大于等于[l,r]的 int main() {
int n, m;
scanf("%d%d", &n, &m);
for(int i = ; i < n; i++) {
for(int j = ; j < m; j++) {
row[j] = ;
int a; scanf("%d", &a);
mp[i].push_back(a);
}
}
ans[] = ;
for(int i = ; i < n; i++) {
int ma = ;
for(int j = ; j < m; j++) {
if(mp[i][j] >= mp[i-][j]) row[j]++;
else row[j] = ;
if(ma < row[j]) ma = row[j];
}
ans[i+] = ma;
}
int q;
scanf("%d", &q);
while(q--) {
int l, r;
scanf("%d%d", &l, &r);
if(ans[r] >= r - l + ) puts("Yes");
else puts("No");
}
return ;
}

Codeforces 777C:Alyona and Spreadsheet(思维)的更多相关文章

  1. Codeforces 777C Alyona and Spreadsheet(思维)

    题目链接 Alyona and Spreadsheet 记a[i][j]为读入的矩阵,c[i][j]为满足a[i][j],a[i - 1][j], a[i - 2][j],......,a[k][j] ...

  2. Codeforces 777C Alyona and Spreadsheet

    C. Alyona and Spreadsheet time limit per test:1 second memory limit per test:256 megabytes input:sta ...

  3. Codeforces 777C - Alyona and Spreadsheet - [DP]

    题目链接:http://codeforces.com/problemset/problem/777/C 题意: 给定 $n \times m$ 的一个数字表格,给定 $k$ 次查询,要你回答是否存在某 ...

  4. codeforces 777C.Alyona and Spreadsheet 解题报告

    题目链接:http://codeforces.com/problemset/problem/777/C 题目意思:给出一个 n * m 的矩阵,然后问 [l, r] 行之间是否存在至少一列是非递减序列 ...

  5. C Alyona and Spreadsheet Codeforces Round #401(Div. 2)(思维)

    Alyona and Spreadsheet 这就是一道思维的题,谈不上算法什么的,但我当时就是不会,直到别人告诉了我,我才懂了的.唉 为什么总是这么弱呢? [题目链接]Alyona and Spre ...

  6. Codeforces Round #401 (Div. 2) C Alyona and Spreadsheet —— 打表

    题目链接:http://codeforces.com/contest/777/problem/C C. Alyona and Spreadsheet time limit per test 1 sec ...

  7. codeforces 777C

    C.Alyona and Spreadsheet During the lesson small girl Alyona works with one famous spreadsheet compu ...

  8. Codeforces777C Alyona and Spreadsheet 2017-05-04 17:46 103人阅读 评论(0) 收藏

    C. Alyona and Spreadsheet time limit per test 1 second memory limit per test 256 megabytes input sta ...

  9. Codeforces E. Alyona and a tree(二分树上差分)

    题目描述: Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

随机推荐

  1. String转Color

    原文:String转Color 很硬性的转换,谁知道更好的忘不吝赐教啊. /// <summary> /// String To Color /// </summary> // ...

  2. CentOS 7.3 源码安装apache 2.4.16配置基于域名的虚拟主机

    主配置文件末尾添加一条配置: [root@vm2 ~]# vim /usr/local/apache/conf/httpd.conf Include conf/vhosts.conf 在conf目录下 ...

  3. WPF ListBox的内容属性Items

    <Window x:Class="XamlTest.Window3"        xmlns="http://schemas.microsoft.com/winf ...

  4. HALCON 语句的分类

    绿色:注释 褐色:控制和开发算子 蓝色:图像获取和处理算子 浅蓝色:外部函数

  5. WPF常见内存泄露

    Event handlers leak This type of leak occurs when subscribing an object (let's call it listener) to ...

  6. Ubuntu服务器搭建

    Ubuntu16 搭建Git 服务器 - 濮成林 - 博客园 https://www.cnblogs.com/charliePU/p/7528226.html Ubuntu 搭建 GitLab 笔记 ...

  7. ASP如何实现注册后发送激活邮件?

    <% Sub Sendemail(title,content,email) Set jmail = Server.CreateObject("JMAIL.Message") ...

  8. .NET环境下有关打印页面设置、打印机设置、打印预览对话框的实现

    原文:.NET环境下有关打印页面设置.打印机设置.打印预览对话框的实现 我个人认为,开发MIS,首先就得解决网格的问题,而开发工具为我们提供了如DataGrid.MSHFlexGrid的控件.其次,是 ...

  9. NBU客户端安装失败

    该服务器是阿里云上的centos6.8,是用来做oracle服务器,买来之后进行测试,发现没有安装图形化界面,还有部分包也没有安装.在oracle安装完成之后,尝试安装NBU的客户端,结果发生报错:T ...

  10. Entity Framework的查询

    Entity Framework是个好东西,虽然没有Hibernate功能强大,但使用更简便.今天整理一下常见SQL如何用EF来表达,Func形式和Linq形式都会列出来(本人更喜欢Func形式). ...