# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1069719 |
2024-08-22T08:30:47 Z |
vjudge1 |
Toy (CEOI24_toy) |
C++17 |
|
62 ms |
30404 KB |
#include <bits/stdc++.h>
#define div /
#define ll long long
#define fore(i, l, r) for(int i=int(l); i<int(r); i++)
#define sz(a) int((a).size())
using namespace std;
const int INF = 1e9;
const int MX = 5e5 + 23;
const int MOD = 1000000007;
const int MAX_N = 5e5+23;
const int N = 1e6;
int ansX,ansY,ans;
int w,h,k,l,xh,yh,xv,yv;
int visited[51][51][51][51];
char grid[1505][1505];
vector<pair<int,int>>monsters;
pair<int,int> overlap(int Xh, int Yh, int Xv, int Yv) {
if(Yv >= Yh and Yv <= (Yh+k-1) and Xh >= Xv and Xh <= (Xv+l-1))
return {Xh,Yv};
return {-1,-1};
}
void rekurzija(int Xh, int Yh, int Xv, int Yv) {
pair<int,int>check = overlap(Xh,Yh,Xv,Yv);
fore(i,0,monsters.size()) {
if(monsters[i].second == Yv and monsters[i].first >= Xv and monsters[i].first <= Xv+l-1) // dodiruje ga vertical linija
return;
if(monsters[i].first == Xh and monsters[i].second >= Yv and monsters[i].second <= Yv+k-1) // dodiruje ga horizontal linija
return;
}
if(check.first == -1 and check.second == -1)
return;
else if(check.first == ansX and check.second == ansY) {
ans=1;
return;
} else if(visited[Xh][Yh][Xv][Yv])
return;
visited[Xh][Yh][Xv][Yv] = 1;
if(Xh > 0)
rekurzija(Xh-1,Yh,Xv,Yv);
if(Xh < h-1)
rekurzija(Xh+1,Yh,Xv,Yv);
if(Yh > 0)
rekurzija(Xh,Yh-1,Xv,Yv);
if(Yh < w-k)
rekurzija(Xh,Yh+1,Xv,Yv);
if(Xv > 0)
rekurzija(Xh,Yh,Xv-1,Yv);
if(Xv < h-l)
rekurzija(Xh,Yh,Xv+1,Yv);
if(Yv > 0)
rekurzija(Xh,Yh,Xv,Yv-1);
if(Yv < w-1)
rekurzija(Xh,Yh,Xv,Yv+1);
}
void solve() {
cin >> w >> h >> k >> l;
cin >> xh >> yh >> xv >> yv;
fore(i,0,h) {
fore(j,0,w) {
cin >> grid[i][j];
if(grid[i][j] == '*') {
ansX = i;
ansY = j;
} else if(grid[i][j] == 'X')
monsters.push_back({i,j});
}
}
rekurzija(yh,xh,yv,xv);
if(ans)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
int main() {
ios::sync_with_stdio(false);
int t=1;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
35 ms |
24440 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
2888 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
464 KB |
Output is correct |
15 |
Correct |
42 ms |
23128 KB |
Output is correct |
16 |
Correct |
34 ms |
20156 KB |
Output is correct |
17 |
Correct |
42 ms |
22364 KB |
Output is correct |
18 |
Incorrect |
62 ms |
30404 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
35 ms |
24440 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
2888 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
464 KB |
Output is correct |
15 |
Correct |
42 ms |
23128 KB |
Output is correct |
16 |
Correct |
34 ms |
20156 KB |
Output is correct |
17 |
Correct |
42 ms |
22364 KB |
Output is correct |
18 |
Incorrect |
62 ms |
30404 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
7 ms |
10240 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
35 ms |
24440 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
2888 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
464 KB |
Output is correct |
15 |
Correct |
42 ms |
23128 KB |
Output is correct |
16 |
Correct |
34 ms |
20156 KB |
Output is correct |
17 |
Correct |
42 ms |
22364 KB |
Output is correct |
18 |
Incorrect |
62 ms |
30404 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
35 ms |
24440 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
2888 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
464 KB |
Output is correct |
15 |
Correct |
42 ms |
23128 KB |
Output is correct |
16 |
Correct |
34 ms |
20156 KB |
Output is correct |
17 |
Correct |
42 ms |
22364 KB |
Output is correct |
18 |
Incorrect |
62 ms |
30404 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |