답안 #1090993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090993 2024-09-19T11:54:11 Z Pajaraja Toy (CEOI24_toy) C++17
0 / 100
16 ms 13404 KB
#include <bits/stdc++.h>
#define MAXN 1507
using namespace std;
bool b[MAXN][MAXN],vi[MAXN][MAXN];
int rb[MAXN][MAXN],ub[MAXN][MAXN],db[MAXN][MAXN],lb[MAXN][MAXN],k,l;
void dfs(int x,int y)
{
    vi[x][y]=true;
    if(!b[x][y+1] && !vi[x][y+1]) {
        int left=max(lb[x][y],lb[x][y+1]),right=min(rb[x][y],rb[x][y+1]);
        if(right-left>k) dfs(x,y+1);
    }
    if(!b[x][y-1] && !vi[x][y-1]) {
        int left=max(lb[x][y],lb[x][y-1]),right=min(rb[x][y],rb[x][y-1]);
        if(right-left>k) dfs(x,y-1);
    }
    if(!b[x+1][y] && !vi[x+1][y]) {
        int up=max(ub[x][y],ub[x+1][y]),down=min(db[x][y],db[x+1][y]);
        if(down-up>l) dfs(x+1,y);
    }
    if(!b[y][x-1] && !vi[y][x-1]) {
        int up=max(ub[x][y],ub[x-1][y]),down=min(db[x][y],db[x-1][y]);
        if(down-up>l) dfs(x-1,y);
    }

}
int main(){
    int w,h,xh,yh,xv,yv;
    cin>>w>>h>>l>>k>>xh>>yh>>xv>>yv;
    int xt,yt,xs=xv+1,ys=yh+1;
    for(int i=0;i<h;i++) {
        string s;
        cin>>s;
        for(int j=0;j<w;j++){
            if(s[j]=='*'){
                yt=i+1;
                xt=j+1;
            }
            if(s[j]=='X') b[j+1][i+1]=true;
        }
    }
    for(int i=1;i<=h;i++) b[0][i]=b[w+1][i]=true;
    for(int i=1;i<=w;i++) b[i][0]=b[i][h+1]=true;
    for(int i=1;i<=h;i++) {
        int ls;
        for(int j=0;j<=w;j++) {
            if(b[j][i]) ls=j;
            lb[j][i]=ls;
        }
        for(int j=w+1;j>0;j--) {
            if(b[j][i]) ls=j;
            rb[j][i]=ls;
        }
    }
    for(int i=1;i<=w;i++) {
        int ls;
        for(int j=0;j<=h;j++) {
            if(b[i][j]) ls=j;
            ub[i][j]=ls;
        }
        for(int j=h+1;j>0;j--) {
            if(b[i][j]) ls=j;
            db[i][j]=ls;
        }
    }
    dfs(xs,ys);
    if(vi[xt][yt]) cout<<"YES";
    else cout<<"NO";
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:67:17: warning: 'yt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |     if(vi[xt][yt]) cout<<"YES";
      |        ~~~~~~~~~^
Main.cpp:67:17: warning: 'xt' may be used uninitialized in this function [-Wmaybe-uninitialized]
Main.cpp:59:21: warning: 'ls' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |             ub[i][j]=ls;
      |             ~~~~~~~~^~~
Main.cpp:48:21: warning: 'ls' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |             lb[j][i]=ls;
      |             ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 860 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 860 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 2392 KB Output is correct
4 Correct 16 ms 13144 KB Output is correct
5 Correct 12 ms 13404 KB Output is correct
6 Incorrect 3 ms 3676 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 860 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 860 KB Output isn't correct
4 Halted 0 ms 0 KB -