#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
const int lim = 1505;
int H, n, m, V, xh, yh, xv, yv, x_target, y_target, f[lim][lim];
int get(int x, int y, int u, int v){
return f[u][v] - (x == 0 ? 0 : f[x - 1][v]) - (y == 0 ? 0 : f[u][y - 1]) + (x == 0 || y == 0 ? 0 : f[x - 1][y - 1]);
}
char a[lim][lim];
namespace sub12{
const int lim = 90;
bitset<lim>vis[lim][lim][lim];
queue<tuple<int, int, int, int>>q;
bool inside(int i, int l, int r){
return l <= i && r >= i;
}
void work(int xh, int yh, int xv, int yv){
if(xh < 0 || xh >= n || yh < 0 || yh + H > m || xv < 0 || xv + V > n || yv < 0 || yv >= m || get(xh, yh, xh, yh + H - 1) > 0 || get(xv, yv, xv + V - 1, yv) > 0 || vis[xh][yh][xv].test(yv) || !inside(yv, yh, yh + H - 1) || !inside(xh, xv, xv + V - 1)){
return;
}
if(xh == x_target && yv == y_target){
cout << "YES";
exit(0);
}
q.emplace(xh, yh, xv, yv);
vis[xh][yh][xv].set(yv);
}
void solve(){
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
for(int k = 0; k < n; k++){
vis[i][j][k].reset();
}
}
}
work(xh, yh, xv, yv);
while(!q.empty()){
tie(xh, yh, xv, yv) = q.front();
q.pop();
work(xh - 1, yh, xv, yv);
work(xh + 1, yh, xv, yv);
work(xh, yh - 1, xv, yv);
work(xh, yh + 1, xv, yv);
work(xh, yh, xv - 1, yv);
work(xh, yh, xv + 1, yv);
work(xh, yh, xv, yv - 1);
work(xh, yh, xv, yv + 1);
}
cout << "NO";
}
}
namespace sub345{
void solve(){
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> m >> n >> H >> V >> yh >> xh >> yv >> xv;
memset(f, 0, sizeof(f));
for(int i = 0; i < n; i++){
for(int j = 0, sum = 0; j < m; j++){
cin >> a[i][j];
if(a[i][j] == 'X'){
sum++;
}
f[i][j] = sum + (i == 0 ? 0 : f[i - 1][j]);
if(a[i][j] == '*'){
x_target = i;
y_target = j;
}
}
}
if(max(n, m) <= 90){
sub12::solve();
}
else{
sub345::solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:60:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
60 | freopen(taskname".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |