제출 #1365548

#제출 시각아이디문제언어결과실행 시간메모리
1365548talyToy (CEOI24_toy)C++20
35 / 100
1085 ms1114112 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define all(x) (x).begin(),(n).end()
vector<vector<vector<vector<int>>>> marc;
int n, m, l, k;
vector<vector<char> > mat;
vector<pii> viz = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; 

bool sol(int x1, int y1, int x2, int y2){
    // cout << x1 << " "<<y1<<" "<<x2<<" "<<y2<<endl;
    if(x1<0||x1>=n||y1<0||y1>=m||x2<0||x2>=n||y2<0||y2>=m)return 0;
    if(x1>=x2&&x1<=x2+l-1&&y2>=y1&&y2<=y1+k-1){
        if(marc[x1][y1][x2][y2]!=0)return 0;
        marc[x1][y1][x2][y2]=1;
        for(int i=y1; i<=y1+k-1; i++){
            if(i<0||i>=m||mat[x1][i]=='X')return 0;
        }
        for(int i=x2; i<=x2+l-1; i++){
            if(i<0||i>=n||mat[i][y2]=='X')return 0;
        }
        if(mat[x1][y2]=='*')return 1;
        for(auto [ax, ay]:viz){
            if(sol(x1+ax, y1+ay, x2, y2))return 1;
            if(sol(x1, y1, x2+ax, y2+ay))return 1;
        }
    }
    return 0;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k >> l;
    swap(n, m);
    mat.resize(n, vector<char>(m));
    marc.resize(n, vector<vector<vector<int>>>(m, vector<vector<int>>(n, vector<int>(m, 0))));
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    swap(x1, y1);
    swap(x2, y2);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> mat[i][j];
        }
    }
    if(sol(x1, y1, x2, y2)){
        cout << "YES"<<endl;
    }else cout << "NO"<<endl;
    
}



















#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…