답안 #1113840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1113840 2024-11-17T15:06:41 Z EfeBabagil Toy (CEOI24_toy) C++14
0 / 100
13 ms 7416 KB
#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)
        break;
        if (arr[e.first][e.second-i] == 'X')
        break;
        
        if(visk[e.first][e.second-i])
        {
            control1=1;
        }
    }
    for(int i=0;i<l;i++){
        if(e.first-i<0)
        break;
        if (arr[e.first-i][e.second] == 'X')
        break;
	    
        if(visl[e.first-i][e.second])
        {
            control2=1;
        }
    }
    //cout<<control1<<" "<<control2<<endl;
    if(control1&&control2)
    cout<<"YES";
    else
    cout<<"NO";
    
 
 
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Incorrect 1 ms 2384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Incorrect 1 ms 2384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 2 ms 4432 KB Output is correct
4 Correct 9 ms 6416 KB Output is correct
5 Correct 11 ms 6224 KB Output is correct
6 Correct 2 ms 4432 KB Output is correct
7 Correct 13 ms 5968 KB Output is correct
8 Correct 11 ms 6480 KB Output is correct
9 Correct 3 ms 2896 KB Output is correct
10 Correct 6 ms 3976 KB Output is correct
11 Correct 5 ms 4688 KB Output is correct
12 Correct 2 ms 4432 KB Output is correct
13 Correct 4 ms 4624 KB Output is correct
14 Correct 4 ms 4432 KB Output is correct
15 Incorrect 10 ms 7416 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Incorrect 1 ms 2384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Incorrect 1 ms 2384 KB Output isn't correct
4 Halted 0 ms 0 KB -