Submission #1070079

# Submission time Handle Problem Language Result Execution time Memory
1070079 2024-08-22T11:32:17 Z naneosmic Toy (CEOI24_toy) C++17
0 / 100
13 ms 11912 KB
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
vector<vector<int>>najljevlji,najdesniji,najgornji,najdonji;
vector<vector<char>>grid;
int w,h,k,l,xh,yh,xv,yv,x,y;
vector<vector<bool>>visited;
void dfs(int x1,int y1){
    if(visited[x1][y1])return;
    visited[x1][y1]=true;
    if(grid[x1+1][y1]!='X'){
        if(!((najdesniji[x1][y1]>najljevlji[x1+1][y1])||(najdesniji[x1+1][y1]>najljevlji[x1][y1])))
        if(najdesniji[x1+1][y1]<=najljevlji[x1+1][y1])dfs(x1+1,y1);
    }
    if(grid[x1-1][y1]!='X'){
        if(!((najdesniji[x1][y1]>najljevlji[x1-1][y1])||(najdesniji[x1-1][y1]>najljevlji[x1][y1])))
        if(najdesniji[x1-1][y1]<=najljevlji[x1-1][y])dfs(x1-1,y1);
    }
    if(grid[x1][y1+1]!='X'){
        if(!((najgornji[x1][y1]<najdonji[x1][y1+1])||(najgornji[x1][y1+1]<najdonji[x1][y1])))
        if(najgornji[x1][y1+1]>=najdonji[x1][y1+1])dfs(x1,y1+1);
    }
    if(grid[x1][y1-1]!='X'){
        if(!((najgornji[x1][y1]<najdonji[x1][y1-1])||(najgornji[x1][y1-1]<najdonji[x1][y1])))
        if(najgornji[x1][y1-1]>=najdonji[x1][y1-1])dfs(x1,y1-1);
    }
}
signed main(){
    cin>>w>>h>>k>>l>>xh>>yh>>xv>>yv;xh++;yh++;xv++;yv++;
    grid.resize(h+2,vector<char>(w+2,'X'));
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>grid[i][j];
            if(grid[i][j]=='*'){
                x=i;y=j;
            }
        }
    }
    visited.resize(h+2,vector<bool>(w+2,false));
    najljevlji.resize(h+2,vector<int>(w+2,k-1));
    najdesniji.resize(h+2,vector<int>(w+2,0));
    najdonji.resize(h+2,vector<int>(w+2,0));
    najgornji.resize(h+2,vector<int>(w+2,l-1));
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            if(grid[i][j]=='X'){
                for(int num=0;num<k;num++){
                    if((j+num+1)<w+2){
                        if(grid[i][j+num+1]!='X')najljevlji[i][j+num+1]=num;
                        else break;
                    }else break;
                }
                for(int num=0;num<l;num++){
                    if((i+num+1)<h+2){
                        if(grid[i+num+1][j]!='X')najgornji[i+num+1][j]=num;
                        else break;
                    }else break;
                }
            }
        }
    }
    for(int i=h+1;i>=0;i--){
        for(int j=w+1;j>=0;j--){
            if(grid[i][j]=='X'){
                for(int num=0;num<k;num++){
                    if((j-num-1)>=0){
                        if(grid[i][j-num-1]!='X')najdesniji[i][j-num-1]=k-1-num;
                        else break;
                    }else break;
                }
                for(int num=0;num<l;num++){
                    if((i-num-1)>=0){
                        if(grid[i-num-1][j]!='X')najdonji[i-num-1][j]=l-1-num;
                        else break;
                    }else break;
                }
            }
        }
    }
    dfs(yh,xv);
    cout<<((visited[x][y]==true)?"YES\n":"NO\n");
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 0 ms 672 KB Output is correct
21 Correct 1 ms 672 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 0 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 0 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Incorrect 0 ms 604 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 0 ms 672 KB Output is correct
21 Correct 1 ms 672 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 0 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 0 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Incorrect 0 ms 604 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 9 ms 8796 KB Output is correct
5 Correct 8 ms 6928 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 7 ms 4884 KB Output is correct
8 Correct 9 ms 6552 KB Output is correct
9 Correct 2 ms 1368 KB Output is correct
10 Correct 5 ms 3420 KB Output is correct
11 Correct 7 ms 3348 KB Output is correct
12 Correct 2 ms 1372 KB Output is correct
13 Correct 5 ms 3472 KB Output is correct
14 Correct 6 ms 3348 KB Output is correct
15 Correct 10 ms 10332 KB Output is correct
16 Correct 10 ms 9308 KB Output is correct
17 Correct 13 ms 9276 KB Output is correct
18 Correct 11 ms 11864 KB Output is correct
19 Correct 11 ms 11868 KB Output is correct
20 Correct 11 ms 11868 KB Output is correct
21 Correct 12 ms 11864 KB Output is correct
22 Correct 11 ms 11868 KB Output is correct
23 Correct 12 ms 11912 KB Output is correct
24 Correct 12 ms 11868 KB Output is correct
25 Correct 13 ms 11896 KB Output is correct
26 Correct 11 ms 8540 KB Output is correct
27 Correct 10 ms 8536 KB Output is correct
28 Correct 10 ms 8540 KB Output is correct
29 Correct 10 ms 8696 KB Output is correct
30 Correct 11 ms 11348 KB Output is correct
31 Incorrect 10 ms 11096 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 0 ms 672 KB Output is correct
21 Correct 1 ms 672 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 0 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 0 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Incorrect 0 ms 604 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 0 ms 672 KB Output is correct
21 Correct 1 ms 672 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 0 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 0 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Incorrect 0 ms 604 KB Output isn't correct
32 Halted 0 ms 0 KB -