Codeforces 777C 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(思维)的更多相关文章
- Codeforces 777C Alyona and Spreadsheet
C. Alyona and Spreadsheet time limit per test:1 second memory limit per test:256 megabytes input:sta ...
- Codeforces 777C - Alyona and Spreadsheet - [DP]
题目链接:http://codeforces.com/problemset/problem/777/C 题意: 给定 $n \times m$ 的一个数字表格,给定 $k$ 次查询,要你回答是否存在某 ...
- codeforces 777C.Alyona and Spreadsheet 解题报告
题目链接:http://codeforces.com/problemset/problem/777/C 题目意思:给出一个 n * m 的矩阵,然后问 [l, r] 行之间是否存在至少一列是非递减序列 ...
- C Alyona and Spreadsheet Codeforces Round #401(Div. 2)(思维)
Alyona and Spreadsheet 这就是一道思维的题,谈不上算法什么的,但我当时就是不会,直到别人告诉了我,我才懂了的.唉 为什么总是这么弱呢? [题目链接]Alyona and Spre ...
- 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 ...
- codeforces 777C
C.Alyona and Spreadsheet During the lesson small girl Alyona works with one famous spreadsheet compu ...
- 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 ...
- Codeforces E. Alyona and a tree(二分树上差分)
题目描述: Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces 777C:Alyona and Spreadsheet(思维)
http://codeforces.com/problemset/problem/777/C 题意:给一个矩阵,对于每一列定义一个子序列使得mp[i][j] >= mp[i-1][j],即如果满 ...
随机推荐
- unity安装记录
官网直接下载(http://unity3d.com/cn/) 下载完后,会要求输入账号密码.我是先在官网进行一个账号注册,然后登陆即可. 首先会要你输入一个已有的邮箱,进行认证.进入自己邮箱,点击链接 ...
- spark测试几个hadoop的典型例子
1.求每年的最高温度数据格式如下: 0067011990999991950051507004888888889999999N9+00001+999999999999999999999900670119 ...
- “帮你APP”团队冲刺7
1.整个项目预期的任务量 (任务量 = 所有工作的预期时间)和 目前已经花的时间 (所有记录的 ‘已经花费的时间’),还剩余的时间(所有工作的 ‘剩余时间’) : 所有工作的预期时间:88h 目前已经 ...
- 基础_String
String str1="hello"; String str2="hello"; String str3="hello"; String ...
- IOS笔记046-UIApplication/导航控制器
UIApplication 每一个应用都有自己的UIApplication对象,而且是单例的 通过[UIApplication sharedApplication]可以获得这个单例对象 一个iOS程序 ...
- live 555 freebsd 或centos 7.4 实现代理视频直播服务
live 555 freebsd 或centos 7.4 实现代理视频直播服务 the live555 media server 在线直播服务器 关于此服务器 此服务是一个无安全的rtsp服 ...
- tmux使用备忘
创建新的session tmux 查看已有session tmux ls 进入tmux后 默认快捷键前缀为Ctrl+b,可以通过配置文件来修改 从session中断开 C-b d 给session改名 ...
- 被readLine()折腾了一把
虽然写IO方面的程序不多,但BufferedReader/BufferedInputStream倒是用过好几次的,原因是: 它有一个很特别的方法:readLine(),使用起来特别方便,每次读回来的都 ...
- bzoj2115【WC2011】XOR
题意:http://www.lydsy.com/JudgeOnline/problem.php?id=2115 sol :首先考虑处理出DFS树,那么树上的所有非树边可以构成一个简单环 因为所有不在 ...
- BJOI2019退役记
update:不想更这个游记……感觉更了只能说明自己菜得只会打嘴炮……那就让这个污痕一直残缺吧 太菜了,就不发具体分数了…… 被北师大附中的高一选手们吊打致死,退役了 4.6 4.7 4.13 4.1 ...