#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
typedef long long ll;
void dfs(vector<vector<bool>>&a,vector<vector<vector<int>>>&b,int x,int y,int &n, int &m)
{
if(b[x][y][x]<m+1)
{
return;
}
b[x][y][x]=y;
if(a[x][y] && x<n-1)
{
dfs(a,b,x+1,y,n,m);
for(int w=x+1;w<n;w++)
{
b[x][y][w]=b[x+1][y][w];
}
}
if(y<m-1)
{
dfs(a,b,x,y+1,n,m);
if(!a[x][y])
{
for(int w=x+1;w<n;w++)
{
b[x][y][w]=b[x][y+1][w];
}
}
}
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n,m,g,q;
cin>>n>>m>>g;
vector<vector<bool>>a(n,vector<bool>(m));
for(int i=0;i<g;i++)
{
int x,y;
cin>>x>>y;
a[x-1][y-1]=true;
}
vector<vector<vector<int>>>b(n,vector<vector<int>>(m,vector<int>(n,m+1)));
for(int i=0;i<n;i++)
{
dfs(a,b,i,0,n,m);
}
cin>>q;
// for(int i=0;i<n;i++)
// {
/// cout<<b[1][1][i]<<endl;
////}
while(q--)
{
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
x1--;x2--;
y1--;y2--;
if(b[x1][y1][x2]<=y2)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
33340 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
16 ms |
20800 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
22 ms |
33032 KB |
197 token(s): yes count is 25, no count is 172 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
556 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
118 ms |
248764 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
112 ms |
248588 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
121 ms |
248700 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |