Submission #1214789

#TimeUsernameProblemLanguageResultExecution timeMemory
1214789spetrToy (CEOI24_toy)C++20
73 / 100
958 ms1114112 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll mmod = 998244353; #define vl vector<long long> #define vll vector<vector<long long>> ll intersect(ll l1, ll r1, ll l2, ll r2){ ll c =0; return max(c, (min(r1,r2) - max(l1,l2) + 1)); } vector<vector<bool>> visited; ll w,h,k,l; vector<string> graf; vll leva; vll prava; vll up; vll down; void dfs(ll y, ll x){ visited[y][x] = true; vll dirs = {{1,0},{-1,0},{0,1},{0,-1}}; if (graf[y][x] == '*'){ cout << "YES"; exit(0); } for (int i = 0; i < 4; i++){ ll nx, ny; nx = x + dirs[i][0]; ny = y + dirs[i][1]; if (nx >= 0 && ny >= 0 && nx < w && ny < h && graf[ny][nx] != 'X'){ if (visited[ny][nx] == false){ if (intersect(x - prava[y][x], x + leva[y][x], nx - prava[ny][nx], nx + leva[ny][nx]) >= k){ if (intersect(y - down[y][x], y + up[y][x], ny - down[ny][nx], ny + up[ny][nx]) >= l){ visited[ny][nx] = true; dfs(ny, nx); } } } } } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> w >> h >> k >> l; ll kx, ky, lx, ly; cin >> kx >> ky >> lx >> ly; //k-horiznot a l-vertikal for (ll i = 0; i < h; i++){ string radek; cin >> radek; graf.push_back(radek); } for (ll i = 0; i < h; i++){ vector<bool> radek; for (ll j = 0; j < w; j++){ radek.push_back(false); } visited.push_back(radek); } // Kontrola, že se vejdou for (ll i = 0; i < h; i++){ vl radek; for (ll j = 0; j < w; j++){ radek.push_back(0); } leva.push_back(radek); prava.push_back(radek); up.push_back(radek); down.push_back(radek); } for (ll i = 0; i < w; i++){ ll aktual1, aktual2; aktual1 = 0; aktual2 = 0; for (ll j = 0; j < h; j++){ if (graf[j][i] != 'X'){ down[j][i] = aktual1; aktual1++; } else{ aktual1 = 0; } } for (ll j = h-1; j >= 0; j--){ if (graf[j][i] != 'X'){ up[j][i] = aktual2; aktual2++; } else{ aktual2 = 0; } } } for (ll i = 0; i < h; i++){ ll aktual1 = 0; ll aktual2 = 0; for (ll j = 0; j < w; j++){ if (graf[i][j] != 'X'){ prava[i][j] = aktual1; aktual1++; } else{ aktual1 = 0; } } for (ll j = w-1; j >= 0; j--){ if (graf[i][j] != 'X'){ leva[i][j] = aktual2; aktual2++; } else{ aktual2 = 0; } } } dfs(ky, lx); cout << "NO"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...