【题目链接】:http://codeforces.com/contest/777/problem/C

【题意】

给你n行m列的矩阵;

然后给你k个询问[l,r];

问你在第l到第r行,是否存在一个列,这一列的第l到第r行是升序的;

是输出YES,否则输出NO

【题解】

/*
对于每一列;
从小到大枚举行;
对于第i行;
看看从第i个元素能有序多长,dp[i];
然后对于j (j∈[i..i+dp[i]-1]),dp[j] = dp[i]-(i-j);
然后i = i+dp[i];
记录下第i行,dp[i][1..m]中的最大值;
对于每一个询问;
if (l+dp[l]-1>=r)
则yes,否则no; */

【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x) typedef pair<int, int> pii;
typedef pair<LL, LL> pll; const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 1e5+100; vector <int> a[N]; int n, m ,k;
int tdp[N],dp[N]; int main()
{
//freopen("F:\\rush.txt", "r", stdin);
rei(n), rei(m);
rep1(i, 1, n)
{
a[i].pb(-1);
int x;
rep1(j, 1, m)
{
rei(x);
a[i].pb(x);
}
}
rep1(j, 1, m)
{
rep1(i, 1, n)
{
int t = i;
while (t + 1 <= n && a[t][j] <= a[t + 1][j]) t++;
tdp[i] = t - i + 1;
rep1(j, i + 1, t)
tdp[j] = tdp[i] - (j - i);
i = t;
}
rep1(i, 1, n)
dp[i] = max(dp[i], tdp[i]);
}
rei(k);
int l, r;
rep1(i, 1, k)
{
rei(l), rei(r);
if (l + dp[l] - 1 >= r)
puts("Yes");
else
puts("No");
}
return 0;
}

【codeforces 777C】 Alyona and Spreadsheet的更多相关文章

  1. 【39.66%】【codeforces 740C】Alyona and mex

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【81.82%】【codeforces 740B】Alyona and flowers

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【20.23%】【codeforces 740A】Alyona and copybooks

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【30.36%】【codeforces 740D】Alyona and a tree

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【31.58%】【codeforces 682D】Alyona and Strings

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【Codeforces 682C】Alyona and the Tree

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 设dis[v]表示v以上的点到达这个点的最大权值(肯定是它的祖先中的某个点到这个点) 类似于最大连续累加和 当往下走(x,y)这条边的时候,设 ...

  7. Codeforces 777C:Alyona and Spreadsheet(预处理)

    During the lesson small girl Alyona works with one famous spreadsheet computer program and learns ho ...

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

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

  9. 【CodeForces - 682C】Alyona and the Tree(dfs)

    Alyona and the Tree Descriptions 小灵决定节食,于是去森林里摘了些苹果.在那里,她意外地发现了一棵神奇的有根树,它的根在节点 1 上,每个节点和每条边上都有一个数字. ...

随机推荐

  1. JS错误记录 - getStyle代替offset、任意值运动框

    本次练习错误总结: 1. 改变border的宽度,属性名称不是直接写border,而是borderWidth. 2. 运动函数 -- 清除定时器 -- 开启新的定时器.  不是在新定时器开启之后再清除 ...

  2. 洛谷—— P1091 合唱队形

    https://www.luogu.org/problem/show?pid=1091#sub  ||  http://codevs.cn/problem/1058/ 题目描述 N位同学站成一排,音乐 ...

  3. linux 查询制定目录的制定内容

    //.点为查找当前目录 下 的 所有 *.php 文件里 有 hello 的文件 find . -name "*.php" | xargs grep "hello&quo ...

  4. vue项目对axios的全局配置

    标准的vue-cli项目结构(httpConfig文件夹自己建的): api.js: //const apiUrl = 'http://test';//测试域名,自己改成自己的 const apiUr ...

  5. Centos 6 DNS Server 配置

    安装bind yum install -y bind bind-chroot bind-utis 如果是Centos 5 # yum -y install bind caching-nameserve ...

  6. c++读取lua配置基础类

    一.内容介绍 把lua作为配置文件,里面的参数值的获取,在他人基础上做了修改,并且补充了一维数组的处理方式. 若有不足之处请多多指教. 对于二维数组,没有成功.希望大家继续补充和修改,非常感谢! 二. ...

  7. eclipse在线安装超级炫酷黑色主题

    Darkest Dark Theme插件: 点击菜单栏 Help --> Eclipse Marketplace,输出Darkest Dark Theme进行搜索,如下图: 本主题有17套编辑器 ...

  8. [Angular] Learn Angular Multi-Slot Content Projection

    Now for au-modal component, we pass in tow component though contenct projection: <au-modal class= ...

  9. IOS日期转为今天昨天形式

    近期项目有类似QQ空间展示动态的UI,模仿了QQ空间的时间显示.在此记录,以备查阅. 这是QQ空间的ui: 时间显示为: 1.今天-->今天 xx:xx(今天 15:39) 2.昨天--> ...

  10. PJSIP开源库详解

    PJSIP是一个包含了SIP.SDP.RTP.RTCP.STUN.ICE等协议实现的开源库.它把基于信令协议SIP的多媒体框架和NAT穿透功能整合成高层次.抽象的多媒体通信API,这套API能够很容易 ...