Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
2017-02-25 15:17
471 查看
题意:
给你一个n*m的矩阵,现在有k个询问,每次给你一个l,r,问你在[l,r]这行中能否有一列数是非递减的顺序
因为这里的数据比较大,然后直接暴力的话,一定会超时的,所以要预处理。然后,图可以用vector来存
给你一个n*m的矩阵,现在有k个询问,每次给你一个l,r,问你在[l,r]这行中能否有一列数是非递减的顺序
因为这里的数据比较大,然后直接暴力的话,一定会超时的,所以要预处理。然后,图可以用vector来存
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <vector> using namespace std; vector <int> a[100005]; int vis[100005]; int main() { int n,m,g; scanf("%d %d",&n,&m); for(int i=0;i<n;i++) for(int j=1;j<=m;j++) { scanf("%d",&g); a[j].push_back(g); } for(int i=0;i<=n;i++) vis[i]=1; for(int i=1;i<=m;i++) { int st=a[i][0],bg=0,time=1; for(int j=1;j<n;j++) { if(st<=a[i][j]) { time++; st=a[i][j]; if(j==n-1) { vis[bg]=max(vis[bg],time); } } else { vis[bg]=max(vis[bg],time); bg=j; time=1; st=a[i][j]; } } } for(int i=1;i<n;i++) vis[i]=max(vis[i],vis[i-1]-1); int k; scanf("%d",&k); for(int i=0;i<k;i++) { int r1,r2; scanf("%d %d",&r1,&r2); r1--; r2--; if(vis[r1]>=(r2-r1+1)) printf("Yes\n"); else printf("No\n"); } return 0; }
相关文章推荐
- codeforce #401 div2 Alyona and Spreadsheet 思维题
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
- Codeforces Round #401 (Div. 2) C Alyona and Spreadsheet —— 打表
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
- Codeforces Round #401 (Div. 2)C. Alyona and Spreadsheet
- Codeforces Round #401 (Div. 2) C - Alyona and Spreadsheet
- Codeforces Round #401(Div. 2)C. Alyona and Spreadsheet【思维】
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet(暴力)
- Codeforces Round #401 (Div. 2)C. Alyona and Spreadsheet
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
- 【离线】【递推】【multiset】 Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
- Codeforces Round #401 (Div. 2)C. Alyona and Spreadsheet(暴力)
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
- Codeforces #401 (Div. 2) C. Alyona and Spreadsheet ( XJBX
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet
- Codeforces Round #401 (Div. 2)C. Alyona and Spreadsheet(暴暴暴力)
- Codeforces Round #401 (Div. 2) C. Alyona and Spreadsheet