#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<long long>a[111111];
vector<int>dp[111111];
int s[111111];
int main()
{
int n,m;
long long x;
cin>>n>>m;
for(int i=0;i<n;i++)
{
int mx=1;
for(int j=0;j<m;j++)
{
cin>>x;
a[i].push_back(x);
if(i==0||(i>0&&x<a[i-1][j]))
{
dp[i].push_back(1);
}
else
{
dp[i].push_back(dp[i-1][j]+1);
mx=max(mx,dp[i][j]);
}
}
s[i]=mx;
}
int k;
int u,v;
cin>>k;
while(k--)
{
scanf("%d%d",&u,&v);
u=u-1;
v=v-1;
int ans=v-u+1;
if(s[v]>=ans)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}
cf - 777C-Alyona and Spreadsheet(预处理)
最新推荐文章于 2020-11-12 23:38:10 发布