#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)
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 || 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 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |