Submission #1113824

#TimeUsernameProblemLanguageResultExecution timeMemory
1113824EfeBabagilToy (CEOI24_toy)C++14
0 / 100
11 ms7368 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; int visk[1505][1505]; int visl[1505][1505]; int32_t main() { int w, h, k, l; cin>>w>>h>>k>>l; int kh,lh,lw,kw; cin>>kw>>kh>>lw>>lh; char arr[h][w]; queue<pair<int,int>> q; pair<int,int> sk,sl,e; for(int i=0;i<h;i++) { for(int j=0;j<w;j++) { cin>>arr[i][j]; if (arr[i][j] == '*') { e = {i,j}; } } } sk={kh,kw}; q.push(sk); visk[sk.first][sk.second] = 1; while (!q.empty()) { pair<int, int> u = q.front(); q.pop(); for (int i = 0; i < 4; i++) { pair<int, int> v = {u.first + dx[i], u.second + dy[i]}; if (v.first < 0 || v.first >= h || v.second < 0 || v.second >= w-k+1) continue; int flag=0; for(int j=0;j<k;j++) { if (arr[v.first][v.second+j] == 'X') { flag=1; break; } } if(flag) continue; if (visk[v.first][v.second]) continue; visk[v.first][v.second] = 1; q.push(v); } } sl={lh,lw}; q.push(sl); visl[sl.first][sl.second] = 1; while (!q.empty()) { pair<int, int> u = q.front(); q.pop(); for (int i = 0; i < 4; i++) { pair<int, int> v = {u.first + dx[i], u.second + dy[i]}; if (v.first < 0 || v.first >= h-l+1 || v.second < 0 || v.second >= w) continue; int flag=0; for(int j=0;j<k;j++) { if (arr[v.first+j][v.second] == 'X') { flag=1; break; } } if(flag) continue; if (visl[v.first][v.second]) continue; visl[v.first][v.second] = 1; q.push(v); } } /* for(int i=0;i<h;i++) { for(int j=0;j<w;j++) { cout<<visk[i][j]<<" "; } cout<<endl; } for(int i=0;i<h;i++) { for(int j=0;j<w;j++) { cout<<visl[i][j]<<" "; } cout<<endl; }*/ int control1=0; int control2=0; for(int i=0;i<k;i++){ if(e.second-i<0) continue; if(visk[e.first][e.second-i]) { control1=1; } } for(int i=0;i<l;i++){ if(e.first-i<0) continue; if(visl[e.first-i][e.second]) { control2=1; } } //cout<<control1<<" "<<control2<<endl; if(control1&&control2) cout<<"YES"; else 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...