模拟-Codeforces 777C
来源:互联网 发布:去除淘宝店铺模块缝隙 编辑:程序博客网 时间:2024/05/18 03:58
题意:给了你两个数代表两行,让你从所有列中找是否满足这两行之间的所有数非递减
思路:首先用vector存数据,然后直接暴力k次询问肯定会超时,我们记录一下每一行按非递减顺序能到达的最大位置,如果它们之间包含了给的两个数的范围就输出Yes,否则输出No
#include<cstdio>#include<cstring>#include<algorithm>#include<vector>using namespace std;const int N = 100010;vector<int>vec[N];int res[N];int main(){ int n,m; scanf("%d%d",&n,&m); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { int x; scanf("%d",&x); vec[i].push_back(x); } } memset(res,0,sizeof(res)); for(int j = 0; j < m; j++) { for(int i = 0; i < n; ) { int flag = i; while(flag + 1 < n && vec[flag][j] <= vec[flag + 1][j]) { flag++; } for(int k = i; k <= flag; k++) res[k] = max(res[k],flag); i = flag + 1; } }// for(int i = 0; i < n; i++)// printf("%d\n",res[i]); int q; scanf("%d",&q); while(q--) { int l,r; scanf("%d%d",&l,&r); l--; r--; if(res[l] >= r) printf("Yes\n"); else printf("No\n"); } return 0;}
阅读全文
0 0
- 模拟-Codeforces 777C
- CodeForces 382C【模拟】
- Codeforces 749C【模拟】
- CodeForces 118C 【模拟】
- Codeforces 863C 模拟
- codeforces 864C 模拟
- 二进制 模拟 codeforces 485C
- Codeforces 230C Shifts(模拟)
- Codeforces 651C Watchmen【模拟】
- CodeForces 350C Bombs(模拟)
- Codeforces-----233C---Cycles模拟
- 爆搜 + 模拟 --- codeforces 475C
- codeforces 591C (模拟)
- 模拟--Codeforces 665C(简单模拟)
- Codeforces 48C The Race 模拟题
- codeforces 460C - Present 二分加模拟
- codeforces--C - Anya and Ghosts(贪心+模拟)
- codeforces 496C Removing Columns (模拟,思维)
- c++位运算
- MySQL日期的加减
- swift学习日记
- MySQL命令-- mysqlbinlog
- 【Leetcode】【python】Permutations
- 模拟-Codeforces 777C
- 通过spring boot构建solr查询实例
- 仿真三件套
- 克拉美罗下界 CRLB的计算
- Leetcode 122 Best Time to Buy and Sell Stock II
- linux下动态库(共享库)
- 使用foreach操作数组
- HDU 5977 树的分治+子集枚举
- 1560 扔人游戏