# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1101923 |
2024-10-17T07:42:31 Z |
Mighilon |
Toy (CEOI24_toy) |
C++17 |
|
7 ms |
2296 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "../Library/debug.h"
#else
#define dbg(x...)
#endif
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i)
#define trav(a, x) for (auto& a : x)
#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
const char nl = '\n';
const int INF = 1e9;
const int MOD = 1e9 + 7;
void solve(){
int w,h,k,l;
cin>>w>>h>>k>>l;
vi s(4);F0R(i,4)cin>>s[i];
int fi=0,fj=0,si=s[1],sj=s[2];
vector<vi> grid(h,vi(w)), pref(h,vi(w));
F0R(i,h){
F0R(j,w){
char c;
cin>>c;
if(c=='*')
fi=i,fj=j;
else if(c=='X')
grid[i][j]=1;
}
}
F0R(i,h){
F0R(j,w){
if(i&&j)
pref[i][j]=pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1]+grid[i][j];
else if(i)
pref[i][j]=pref[i-1][j]+grid[i][j];
else if(j)
pref[i][j]=pref[i][j-1]+grid[i][j];
}
}
auto pref_f=[&](int i, int j, int ii, int jj)->int{
int res=0;
res=pref[ii][jj];
if(i&&j)
res+=pref[i-1][j-1];
if(i)
res-=pref[i-1][jj];
if(j)
res-=pref[ii][j-1];
return res;
};
dbg(pref)
auto f=[&](int l,int k,vector<vi>&good)->void{
F0R(i,h){
F0R(j,w){
int ii=i+l-1,jj=j+k-1;
if(ii<h&&jj<w&&pref_f(i,j,ii,jj)==0){
good[i][j]++;
if(ii<h-1)
good[ii+1][j]--;
if(jj<w-1)
good[i][jj+1]--;
if(jj+1<w&&ii+1<h)
good[ii+1][jj+1]++;
}
}
}
dbg(good);
F0R(j,w)
FOR(i,1,h)
good[i][j]+=good[i-1][j];
F0R(i,h)
FOR(j,1,w)
good[i][j]+=good[i][j-1];
dbg(good);
};
vector<vi> fl(h,vi(w)),fk(h,vi(w));
f(l,1,fl);
f(1,k,fk);
vector<vi> good(h,vi(w));
F0R(i,h)
F0R(j,w)
good[i][j]=fl[i][j]&&fk[i][j];
//F0R(i,h){F0R(j,w)cout<<setw(2)<<good[i][j]<<" ";cout<<nl;}
if(good[si][sj]==0){
cout<<"NO"<<nl;
return;
}
if(si==fi&&sj==fj){
cout<<"YES"<<nl;
return;
}
//cout<<si<<" "<<sj<<nl;
queue<pi> q;
q.push({si,sj});
grid[si][sj]=-1;
int di[4]={1,-1,0,0};
int dj[4]={0,0,1,-1};
while(!q.empty()){
auto [i,j]=q.front();
q.pop();
F0R(d,4){
int vi=i+di[d],vj=j+dj[d];
if(vi<h&&vj<w&&vi>=0&&vj>=0&&good[vi][vj]==1&&grid[vi][vj]!=-1){
grid[vi][vj]=-1;
q.push({vi,vj});
}
}
}
//F0R(i,h){F0R(j,w)cout<<setw(2)<<grid[i][j]<<" ";cout<<nl;}
if(good[fi][fj]!=0&&good[si][sj]!=0&&grid[fi][fj]==-1)
cout<<"YES"<<nl;
else cout<<"NO"<<nl;
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int TC = 1;
// cin >> TC;
while(TC--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
508 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
508 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
5 ms |
2128 KB |
Output is correct |
5 |
Correct |
6 ms |
2128 KB |
Output is correct |
6 |
Correct |
1 ms |
592 KB |
Output is correct |
7 |
Correct |
5 ms |
2128 KB |
Output is correct |
8 |
Correct |
6 ms |
2128 KB |
Output is correct |
9 |
Correct |
2 ms |
848 KB |
Output is correct |
10 |
Correct |
5 ms |
2128 KB |
Output is correct |
11 |
Correct |
5 ms |
2128 KB |
Output is correct |
12 |
Correct |
2 ms |
848 KB |
Output is correct |
13 |
Correct |
5 ms |
2140 KB |
Output is correct |
14 |
Correct |
4 ms |
2128 KB |
Output is correct |
15 |
Correct |
5 ms |
2128 KB |
Output is correct |
16 |
Correct |
5 ms |
1872 KB |
Output is correct |
17 |
Correct |
5 ms |
1872 KB |
Output is correct |
18 |
Correct |
5 ms |
2128 KB |
Output is correct |
19 |
Correct |
5 ms |
2296 KB |
Output is correct |
20 |
Correct |
6 ms |
2128 KB |
Output is correct |
21 |
Correct |
5 ms |
2128 KB |
Output is correct |
22 |
Correct |
5 ms |
2128 KB |
Output is correct |
23 |
Correct |
6 ms |
2208 KB |
Output is correct |
24 |
Correct |
5 ms |
2128 KB |
Output is correct |
25 |
Correct |
5 ms |
2184 KB |
Output is correct |
26 |
Correct |
6 ms |
2128 KB |
Output is correct |
27 |
Correct |
7 ms |
2128 KB |
Output is correct |
28 |
Correct |
5 ms |
2128 KB |
Output is correct |
29 |
Correct |
6 ms |
2128 KB |
Output is correct |
30 |
Correct |
5 ms |
2128 KB |
Output is correct |
31 |
Correct |
5 ms |
2140 KB |
Output is correct |
32 |
Correct |
6 ms |
2128 KB |
Output is correct |
33 |
Correct |
5 ms |
1872 KB |
Output is correct |
34 |
Correct |
5 ms |
2040 KB |
Output is correct |
35 |
Correct |
7 ms |
2040 KB |
Output is correct |
36 |
Correct |
3 ms |
1872 KB |
Output is correct |
37 |
Incorrect |
5 ms |
2128 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
508 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
508 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |