Submission #1039620

# Submission time Handle Problem Language Result Execution time Memory
1039620 2024-07-31T06:01:09 Z Name(#11031) Toy (CEOI24_toy) C++17
0 / 100
24 ms 7608 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
using pii=array<int,2>;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N=1505;
int h,w,k,l,a[N][N],sumH[N][N],sumV[N][N],chk[N][N];
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
pii S[2],E;
bool vis[2][N][N];
string s;
bool chkH(int x,int y){
	return y+k-1<=w&&sumH[x][y+k-1]==sumH[x][y-1]&&chk[x][y+k-1]!=chk[x][y-1];
}
bool chkV(int x,int y){
	return x+l-1<=h&&sumV[x+l-1][y]==sumV[x-1][y]&&chk[x+l-1][y]!=chk[x-1][y];
}
bool chkF(int x,int y,int T){
	if(T%2==0) return chkH(x,y);
	else return chkV(x,y);
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>w>>h>>k>>l;
	cin>>S[0][1]>>S[0][0]>>S[1][1]>>S[1][0];
	S[0][0]++;
	S[0][1]++;
	S[1][0]++;
	S[1][1]++;
	for(int i=1;i<=h;i++){
		cin>>s;
		for(int j=1;j<=w;j++){
			if(s[j-1]=='X') a[i][j]=1;
			else{
				a[i][j]=0;
				if(s[j-1]=='*') E={i,j};
			}
		}
	}
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){
		sumH[i][j]=sumH[i][j-1]+a[i][j];
		sumV[i][j]=sumV[i-1][j]+a[i][j];
	}
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) chk[i][j]=j;
	for(int T=0;T<10;T++){
		queue<pii> que;
		for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) vis[T%2][i][j]=0;
		vis[T%2][S[T%2][0]][S[T%2][1]]=1;
		que.push(S[T%2]);
		while(que.size()){
			pii p=que.front(); que.pop();
			for(int k=0;k<4;k++){
				int x=p[0]+dx[k],y=p[1]+dy[k];
				if(x<1||x>h||y<1||y>w||!chkF(x,y,T)||vis[T%2][x][y]) continue;
				vis[T%2][x][y]=1;
				que.push({x,y});
			}
		}
		for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) chk[i][j]=0;
		for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) if(vis[T%2][i][j]){
			if(T%2==0){
				chk[i][j]++;
				chk[i][j+k]--;
			} else{
				chk[i][j]++;
				chk[i+l][j]--;
			}
		}
		/*for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++) cout<<vis[T%2][i][j];
			cout<<"\n";
		}
		cout<<"\n\n\n";*/
		if(T%2==0){
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) chk[i][j]+=chk[i][j-1];
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) chk[i][j]+=chk[i-1][j];
		} else{
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) chk[i][j]+=chk[i-1][j];
			if(T==9&&chk[E[0]][E[1]]){
				cout<<"YES\n";
				return 0;
			}
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) chk[i][j]+=chk[i][j-1];
		}
	}
	cout<<"NO\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 2 ms 1372 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 0 ms 1116 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 3160 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Incorrect 1 ms 1484 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 2 ms 1372 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 0 ms 1116 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 3160 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Incorrect 1 ms 1484 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 24 ms 7596 KB Output is correct
5 Correct 23 ms 7608 KB Output is correct
6 Correct 3 ms 1884 KB Output is correct
7 Correct 22 ms 7592 KB Output is correct
8 Correct 22 ms 7388 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 6 ms 7516 KB Output is correct
11 Correct 4 ms 7516 KB Output is correct
12 Correct 3 ms 5460 KB Output is correct
13 Correct 5 ms 7516 KB Output is correct
14 Correct 5 ms 7572 KB Output is correct
15 Incorrect 20 ms 7516 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 2 ms 1372 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 0 ms 1116 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 3160 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Incorrect 1 ms 1484 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 2 ms 1372 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 0 ms 1116 KB Output is correct
10 Correct 1 ms 1372 KB Output is correct
11 Correct 1 ms 3160 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Incorrect 1 ms 1484 KB Output isn't correct
16 Halted 0 ms 0 KB -