对询问按右端点排序,对每一列递推出包含当前行的单调不下降串最多向前延伸多少。

用multiset维护,取个最小值,看是否小于等于该询问的左端点。

#include<cstdio>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
multiset<int>S;
#define INF 2147483647
struct Data
{
int l,r,p;
}b[100010];
bool cmp(const Data &a,const Data &b)
{
return a.r<b.r;
}
int n,m,q,ls[100010];
bool anss[100010];
vector<int>a[100010];
int main()
{
// freopen("c.in","r",stdin);
int x;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)
a[i].push_back(0);
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
{
scanf("%d",&x);
a[i].push_back(x);
}
scanf("%d",&q);
for(int i=1;i<=m+1;++i)
a[0].push_back(INF);
for(int i=1;i<=q;++i)
{
scanf("%d%d",&b[i].l,&b[i].r);
b[i].p=i;
}
sort(b+1,b+1+q,cmp);
for(int i=1;i<=q;++i)
{
for(int j=b[i-1].r+1;j<=b[i].r;++j)
for(int k=1;k<=m;++k)
if(a[j][k]<a[j-1][k])
{
multiset<int>::iterator it=S.find(ls[k]);
if(it!=S.end())
S.erase(it);
ls[k]=j;
S.insert(j);
}
if((*S.begin())<=b[i].l)
anss[b[i].p]=1;
}
for(int i=1;i<=q;++i)
puts(anss[i] ? "Yes" : "No");
return 0;
}

【离线】【递推】【multiset】 Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet的更多相关文章

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

  2. 递推DP Codeforces Round #260 (Div. 1) A. Boredom

    题目传送门 /* DP:从1到最大值,dp[i][1/0] 选或不选,递推更新最大值 */ #include <cstdio> #include <algorithm> #in ...

  3. 【递推】Codeforces Round #483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!] D. XOR-pyramid

    题意:定义,对于a数组的一个子区间[l,r],f[l,r]定义为对该子区间执行f操作的值.显然,有f[l,r]=f[l,r-1] xor f[l+1,r].又定义ans[l,r]为满足l<=i& ...

  4. Codeforces Round #401 (Div. 2) 离翻身就差2分钟

    Codeforces Round #401 (Div. 2) 很happy,现场榜很happy,完全将昨晚的不悦忘了.终判我校一片惨白,小董同学怒怼D\E,离AK就差一个C了,于是我AC了C题还剩35 ...

  5. 【贪心】【multiset】 Codeforces Round #401 (Div. 2) B. Game of Credit Cards

    对第一个人的排序,然后从小到大处理,对第一个人的每枚卡片,从第二个人的卡片中选择一个大于等于它的最小的,否则选择一个当前剩下的最小的,这样可以保证负场最少. 如果选择的改成大于它的最小的,就可以保证胜 ...

  6. 递推水题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table

    题目传送门 /* 模拟递推水题 */ #include <cstdio> #include <iostream> #include <cmath> #include ...

  7. Codeforces Round #401 (Div. 2) D Cloud of Hashtags —— 字符串

    题目链接:http://codeforces.com/contest/777/problem/D 题解: 题意:给出n行字符串,对其进行字典序剪辑.我自己的想法是正向剪辑的,即先对第一第二个字符串进行 ...

  8. Codeforces Round #401 (Div. 2)

    和FallDream dalao一起从学长那借了个小号打Div2,他切ABE我做CD,我这里就写下CD题解,剩下的戳这里 AC:All Rank:33 小号Rating:1539+217->17 ...

  9. D Cloud of Hashtags Codeforces Round #401 (Div. 2)

    Cloud of Hashtags [题目链接]Cloud of Hashtags &题意: 给你一个n,之后给出n个串,这些串的总长度不超过5e5,你要删除最少的单词(并且只能是后缀),使得 ...

随机推荐

  1. Reasons to use innodb_file_per_table

    When working with InnoDB, you have two ways for managing the tablespace storage: Throw everything in ...

  2. Codeforces Round #531 (Div. 3) ABCDEF题解

    Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...

  3. hdu Shell Necklace 5730 分治FFT

    Description Perhaps the sea‘s definition of a shell is the pearl. However, in my view, a shell neckl ...

  4. LwIP - raw/callback API、协议栈API(sequential API)、BSD API(或者说 SOCKET API)

    1.使用raw/callback API编程,用户编程的方法是向内核注册各种自定义的回调函数,回调函数是与内核实现交换的唯一方式. recv_udp, accept_function, sent_tc ...

  5. 7月23号day15总结

    数据清洗完成之后开始编写前端,通过spring框架将清洗后数据库中的数据显示在页面中. 框架的搭建和js的使用都在学习阶段,

  6. [CVPR2017]Online Video Object Segmentation via Convolutional Trident Network

    基于三端卷积网络的在线视频目标分割 针对半监督视频目标分割任务,作者采取了和MaskTrace类似的思路,以optical flow为主. 本文亮点在于: 1. 使用共享backbone,三输出的自编 ...

  7. 使用Word2010发布博客文章

    发布博客可以直接在web页面上面编辑,也可以使用客户端编辑,其中客户端支持windows live writer以及word本身的发布博客功能.个人试用后倾向于使用word发布博客文章. 下面的内容转 ...

  8. 在liberty中通过LTPA设置单点登录

    不要忘了下面的设置,参考: https://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp. ...

  9. WebComponents001

    Sample1: ShadowDom 隔离style,替换显示内容 <button>Hello, world!</button> <script> var host ...

  10. 谈数据中心SDN与NFV

    看到一篇谈论SDN与NFV的文章,分析的还不错,贴过来方便自己后续查阅: http://network.chinabyte.com/175/13095675.shtml 论数据中心SDN与NFV技术关 ...