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. POJ - 2991 Crane (段树+计算几何)

    Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of variou ...

  2. JS 中click和onclick的区别

    1.onclick是绑定事件,告诉浏览器在鼠标点击时候要做什么 2.click本身是方法,作用是触发onclick事件,只要执行了元素的click()方法,就会触发onclick事件

  3. sqlserver从xlsx读取数据

    exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Querie ...

  4. Win8 Metro(C#)数字图像处理--2.48Canny边缘检测算法

    原文:Win8 Metro(C#)数字图像处理--2.48Canny边缘检测算法  [算法说明] Canny边缘检测算法可以分为4步:高斯滤波器平滑处理.梯度计算.非极大值抑制.双阈值边缘检 测和 ...

  5. 安装CUDA和cuDNN

    GPU和CPU区别 1,CPU主要用于处理通用逻辑,以及各种中断事物 2,GPU主要用于计算密集型程序,可并行运作: NVIDIA 的 GeForce 显示卡系列采用 GPU 特性进行快速计算,渲染电 ...

  6. Ubuntu设置MySQL允许远程访问

    1.注释bind-address = 127.0.0.1. 代码如下: > sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf 将bind-address = ...

  7. C#最基本的数据库增删改查

    namespace access { public partial class Form1 : Form { //定义数据库的连接路径 string txtConn ="Provider=M ...

  8. Windows Phone锁屏背景相关代码

    LockScreenManager: 启用应用程序,查看该应用程序是否是当前锁定屏幕背景提供程序,并将自己设置为提供程序. 属性: IsProvidedByCurrentApplication 只读指 ...

  9. Win10自带应用不喜欢?一条命令全部卸载

    与Win8/Win8.1一样,Win10中继续内置了应用商店,所不同的是Windows10中已升级为通用应用商店,具有跨平台特性.可能有的朋友仍不喜欢使用Modern应用,因为传统桌面应用几乎能够满足 ...

  10. How Qt Signals and Slots Work(感觉是通过Meta根据名字来调用)

    Qt is well known for its signals and slots mechanism. But how does it work? In this blog post, we wi ...