题目链接 Alyona and Spreadsheet

记a[i][j]为读入的矩阵,c[i][j]为满足a[i][j],a[i - 1][j], a[i - 2][j],......,a[k][j]不上升的k的最小值。

d[i]为max(c[i][j]) (1 <= j <= m)

那么对于每次询问l,r,若d[r] <= l,那么就符合,反之不符。

因为这里只说名了1 <= nm <= 100000,所以二维数组两个维的大小不确定。

数据可能有n=1, m=100000,也可能有n = 100000, m = 1。

所以我把二维数组开成了一维的。

 #include <bits/stdc++.h>

 using namespace std;

 #define rep(i, a, b)              for(int i(a); i <= (b); ++i)
#define INF 1 << 30 const int N = + ; int a[N], c[N], d[N];
int n, m, q, x, y; int calc(int i, int j){
return (i - ) * m + j;
} int main(){ scanf("%d%d", &n, &m);
rep(i, , m) scanf("%d", a + i);
rep(i, , m) c[calc(, i)] = ;
rep(i, , n){
rep(j, , m){
scanf("%d", &x);
if (a[j] <= x){
c[calc(i, j)] = c[calc(i - , j)];
a[j] = x;
} else{
c[calc(i, j)] = i;
a[j] = x;
}
}
} rep(i, , n) d[i] = INF;
rep(i, , n){
rep(j, , m) d[i] = min(d[i], c[calc(i, j)]);
} scanf("%d", &q);
while (q--){
scanf("%d%d", &x, &y);
puts(d[y] <= x ? "Yes" : "No");
} return ; }

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

  1. Codeforces 777C Alyona and Spreadsheet

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

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

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

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

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

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

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

  5. 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 ...

  6. codeforces 777C

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

  7. 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 ...

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

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

  9. Codeforces 777C:Alyona and Spreadsheet(思维)

    http://codeforces.com/problemset/problem/777/C 题意:给一个矩阵,对于每一列定义一个子序列使得mp[i][j] >= mp[i-1][j],即如果满 ...

随机推荐

  1. ipv4配置

  2. vba中获取当前sheet页的名称,当前单元格所在位置

    fname = ActiveSheet.Name-------获取当前sheet页的名称        Sname = "" & fname & "&qu ...

  3. Spring核心技术(十四)——ApplicationContext的额外功能

    在前文的介绍中我们知道,org.springframework.beans.factory包提供了一些基本的功能来管理和控制Bean,甚至通过编程的方式来实现.org.springframework. ...

  4. Linux下安装nginx,以及启动和停止

    1.安装 安装nginx之前,首先确保系统已经安装了依赖:g++.gcc.openssl-devel.pcre-devel和zlib-devel软件 yum install gcc-c++ yum - ...

  5. dp专练

    dp练习. codevs 1048 石子归并 区间dp #include<cstdio> #include<algorithm> #include<cstring> ...

  6. P3398 仓鼠找sugar(树链剖分)

    P3398 仓鼠找sugar 题目描述 小仓鼠的和他的基(mei)友(zi)sugar住在地下洞穴中,每个节点的编号为1~n.地下洞穴是一个树形结构.这一天小仓鼠打算从从他的卧室(a)到餐厅(b),而 ...

  7. 【Word Search】cpp

    题目: Given a 2D board and a word, find if the word exists in the grid. The word can be constructed fr ...

  8. IOS开发学习笔记023-UIToolBar的使用

    这里使用代码实现 大概过程: 1.创建工具条 2.创建插入条 3.添加头像.标签.删除按钮 4.点击头像获取标签信息 做一个简单的联系人列表,可以添加删除联系人,现在还没有添加头像和文字,接下来慢慢添 ...

  9. ogre3D学习基础14 -- 雾化效果与天空面,天空盒,天空穹

    前几天设置天空盒时一直出问题,现在问题终于解决了,问题来的莫名其妙,走的也莫名其妙. 第一,还是框架,我们依然使用ExampleApplication文件,框架如下 #include "Ex ...

  10. idea的ssm搭建(复制)

    1.工具/原料 • apache-tomcat-7.0.63 http://download.csdn.net/detail/lxfhahaha/9778163 • apache-maven-3.3. ...