답안 #1090994

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090994 2024-09-19T11:56:46 Z Pajaraja Toy (CEOI24_toy) C++17
9 / 100
15 ms 14612 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[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);
    }

}
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 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 440 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 440 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 440 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 9 ms 11976 KB Output is correct
5 Correct 8 ms 10504 KB Output is correct
6 Correct 2 ms 3932 KB Output is correct
7 Correct 7 ms 9156 KB Output is correct
8 Correct 7 ms 10076 KB Output is correct
9 Correct 3 ms 5720 KB Output is correct
10 Correct 4 ms 7000 KB Output is correct
11 Correct 4 ms 7004 KB Output is correct
12 Correct 2 ms 3016 KB Output is correct
13 Correct 4 ms 7004 KB Output is correct
14 Correct 5 ms 7004 KB Output is correct
15 Correct 13 ms 13288 KB Output is correct
16 Correct 9 ms 12380 KB Output is correct
17 Correct 9 ms 12176 KB Output is correct
18 Correct 10 ms 14540 KB Output is correct
19 Correct 10 ms 14612 KB Output is correct
20 Correct 11 ms 14604 KB Output is correct
21 Correct 10 ms 14428 KB Output is correct
22 Correct 11 ms 14428 KB Output is correct
23 Correct 11 ms 14428 KB Output is correct
24 Correct 15 ms 14428 KB Output is correct
25 Correct 10 ms 14540 KB Output is correct
26 Correct 9 ms 11868 KB Output is correct
27 Correct 9 ms 11868 KB Output is correct
28 Correct 9 ms 11972 KB Output is correct
29 Correct 8 ms 11864 KB Output is correct
30 Correct 13 ms 14276 KB Output is correct
31 Correct 9 ms 13748 KB Output is correct
32 Correct 11 ms 14172 KB Output is correct
33 Correct 9 ms 13404 KB Output is correct
34 Correct 10 ms 13404 KB Output is correct
35 Correct 10 ms 13660 KB Output is correct
36 Correct 4 ms 7152 KB Output is correct
37 Correct 7 ms 9412 KB Output is correct
38 Correct 6 ms 8796 KB Output is correct
39 Correct 6 ms 9052 KB Output is correct
40 Correct 7 ms 9308 KB Output is correct
41 Correct 5 ms 8796 KB Output is correct
42 Correct 10 ms 12124 KB Output is correct
43 Correct 10 ms 12632 KB Output is correct
44 Correct 9 ms 11612 KB Output is correct
45 Correct 9 ms 13144 KB Output is correct
46 Correct 5 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 440 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 440 KB Output is correct
3 Incorrect 1 ms 860 KB Output isn't correct
4 Halted 0 ms 0 KB -