답안 #1070130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1070130 2024-08-22T11:48:48 Z naneosmic Toy (CEOI24_toy) C++14
0 / 100
16 ms 11884 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+1][y1]<=najljevlji[x1+1][y1])
        if(!((najdesniji[x1][y1]>najljevlji[x1+1][y1])||(najdesniji[x1+1][y1]>najljevlji[x1][y1])))dfs(x1+1,y1);
    }
    if(grid[x1-1][y1]!='X'){
        if(najdesniji[x1-1][y1]<=najljevlji[x1-1][y])
        if(!((najdesniji[x1][y1]>najljevlji[x1-1][y1])||(najdesniji[x1-1][y1]>najljevlji[x1][y1])))dfs(x1-1,y1);
    }
    if(grid[x1][y1+1]!='X'){
        if(najgornji[x1][y1+1]>=najdonji[x1][y1+1])
        if(!((najgornji[x1][y1]<najdonji[x1][y1+1])||(najgornji[x1][y1+1]<najdonji[x1][y1])))dfs(x1,y1+1);
    }
    if(grid[x1][y1-1]!='X'){
        if(najgornji[x1][y1-1]>=najdonji[x1][y1-1])
        if(!((najgornji[x1][y1]<najdonji[x1][y1-1])||(najgornji[x1][y1-1]<najdonji[x1][y1])))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");
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 856 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 0 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 0 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 856 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 0 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 0 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 11 ms 8816 KB Output is correct
5 Correct 11 ms 7004 KB Output is correct
6 Correct 1 ms 1208 KB Output is correct
7 Correct 8 ms 4976 KB Output is correct
8 Correct 8 ms 6748 KB Output is correct
9 Correct 2 ms 1372 KB Output is correct
10 Correct 5 ms 3420 KB Output is correct
11 Correct 4 ms 3420 KB Output is correct
12 Correct 2 ms 1372 KB Output is correct
13 Correct 6 ms 3420 KB Output is correct
14 Correct 8 ms 3420 KB Output is correct
15 Correct 11 ms 10340 KB Output is correct
16 Correct 10 ms 9308 KB Output is correct
17 Correct 10 ms 9308 KB Output is correct
18 Correct 16 ms 11868 KB Output is correct
19 Correct 14 ms 11864 KB Output is correct
20 Correct 11 ms 11868 KB Output is correct
21 Correct 11 ms 11864 KB Output is correct
22 Correct 13 ms 11884 KB Output is correct
23 Correct 11 ms 11864 KB Output is correct
24 Correct 12 ms 11844 KB Output is correct
25 Correct 13 ms 11868 KB Output is correct
26 Correct 9 ms 8540 KB Output is correct
27 Correct 11 ms 8540 KB Output is correct
28 Correct 9 ms 8540 KB Output is correct
29 Correct 9 ms 8540 KB Output is correct
30 Correct 10 ms 11364 KB Output is correct
31 Incorrect 11 ms 10852 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 856 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 0 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 0 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 856 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 0 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 0 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 -