#include <bits/stdc++.h>
using namespace std;
#define int long long
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int visk[1505][1505];
int visl[1505][1505];
int32_t main()
{
int w, h, k, l;
cin>>w>>h>>k>>l;
int kh,lh,lw,kw;
cin>>kw>>kh>>lw>>lh;
char arr[h][w];
queue<pair<int,int>> q;
pair<int,int> sk,sl,e;
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
cin>>arr[i][j];
if (arr[i][j] == '*')
{
e = {i,j};
}
}
}
sk={kh,kw};
q.push(sk);
visk[sk.first][sk.second] = 1;
while (!q.empty())
{
pair<int, int> u = q.front();
q.pop();
for (int i = 0; i < 4; i++) {
pair<int, int> v = {u.first + dx[i], u.second + dy[i]};
if (v.first < 0 || v.first >= h || v.second < 0 || v.second >= w-k+1) continue;
int flag=0;
for(int j=0;j<k;j++)
{
if (arr[v.first][v.second+j] == 'X')
{
flag=1;
break;
}
}
if(flag)
continue;
if (visk[v.first][v.second])
continue;
visk[v.first][v.second] = 1;
q.push(v);
}
}
sl={lh,lw};
q.push(sl);
visl[sl.first][sl.second] = 1;
while (!q.empty())
{
pair<int, int> u = q.front();
q.pop();
for (int i = 0; i < 4; i++) {
pair<int, int> v = {u.first + dx[i], u.second + dy[i]};
if (v.first < 0 || v.first >= h-l+1 || v.second < 0 || v.second >= w) continue;
int flag=0;
for(int j=0;j<k;j++)
{
if (arr[v.first+j][v.second] == 'X')
{
flag=1;
break;
}
}
if(flag)
continue;
if (visl[v.first][v.second])
continue;
visl[v.first][v.second] = 1;
q.push(v);
}
}
/*
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
cout<<visk[i][j]<<" ";
}
cout<<endl;
}
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
cout<<visl[i][j]<<" ";
}
cout<<endl;
}*/
int control1=0;
int control2=0;
for(int i=0;i<k;i++){
if(e.second-i<0)
break;
if (arr[e.first][e.second-i] == 'X')
break;
if(visk[e.first][e.second-i])
{
control1=1;
}
}
for(int i=0;i<l;i++){
if(e.first-i<0)
break;
if (arr[e.first-i][e.second] == 'X')
break;
if(visl[e.first-i][e.second])
{
control2=1;
}
}
//cout<<control1<<" "<<control2<<endl;
if(control1&&control2)
cout<<"YES";
else
cout<<"NO";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2556 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Incorrect |
2 ms |
592 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2556 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Incorrect |
2 ms |
592 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
10 ms |
4176 KB |
Output is correct |
5 |
Correct |
13 ms |
4344 KB |
Output is correct |
6 |
Correct |
2 ms |
1128 KB |
Output is correct |
7 |
Correct |
24 ms |
4024 KB |
Output is correct |
8 |
Correct |
23 ms |
4176 KB |
Output is correct |
9 |
Correct |
3 ms |
848 KB |
Output is correct |
10 |
Correct |
6 ms |
2188 KB |
Output is correct |
11 |
Correct |
4 ms |
592 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
13 |
Correct |
4 ms |
504 KB |
Output is correct |
14 |
Correct |
4 ms |
336 KB |
Output is correct |
15 |
Incorrect |
11 ms |
7248 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2556 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Incorrect |
2 ms |
592 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2556 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Incorrect |
2 ms |
592 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |