제출 #1342896

#제출 시각아이디문제언어결과실행 시간메모리
1342896thesentroToy (CEOI24_toy)C++20
100 / 100
282 ms337464 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
ll mod = 998244353;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b>0)
    {
        if (b&1)
            res = (res*a)%mod;
        a = (a*a)%mod;
        b>>=1;
    }
    return res;
}
ll gcd(ll x, ll y)
{
    if (y==0)
        return x;
    return gcd(y, x%y);
}
ll w,h,k,L;
ll maxi = 2000;
vector<vector<ll>>vis(maxi, vector<ll>(maxi, 0));
vector<vector<ll>>up(maxi, vector<ll>(maxi, 0)), down(maxi, vector<ll>(maxi, 0)),  
lf(maxi, vector<ll>(maxi, 0)),  rg(maxi, vector<ll>(maxi, 0));
vector<ll>dx = {-1, 0, 1, 0};
vector<ll>dy = {0, -1, 0, 1};
ll a,b,c,d;
vector<vector<char>>v(maxi, vector<char>(maxi));
bool check (ll x, ll y, ll xx, ll yy)
{
    if (xx>h or xx<1 or yy>w or yy<1) return false;
    if (v[xx][yy]=='X') return false;
    if (xx==x+1 or xx==x-1)
    {
        ll l = min(lf[x][y], lf[xx][yy]);
        ll r = min(rg[x][y], rg[xx][yy]);
        if (l+r-1>=k)
            return true;
        else
            return false;
    }
    if (yy==y-1 or yy==y+1)
    {
        ll l = min(up[x][y], up[xx][yy]);
        ll r = min(down[x][y], down[xx][yy]);
        if (l+r-1>=L)
            return true;
        else
            return false;
    }
}
void dfs(ll x, ll y)
{
    vis[x][y] = 1;
    // cout<<x<<" "<<y<<endl;
    for (int i=0 ; i<=3 ; i++)
    {
        ll xx = x+dx[i];
        ll yy = y+dy[i];
        if (vis[xx][yy]==0 and check(x, y, xx, yy))
            dfs(xx, yy);
    }
}
void solve()
{
    cin>>w>>h>>k>>L;
    cin>>a>>b>>c>>d;
    ll e1, e2;
    for (int i=1 ; i<=h ; i++)
    {
        for (int j=1 ; j<=w ; j++)
        {
            cin>>v[i][j];
            if (v[i][j]=='*')
            {
                e1 = i;
                e2 = j;
            }
        }
    }
    
    for (int i=1 ; i<=h ; i++)
    {
        for (int j=1 ; j<=w ; j++)
        {
            if (v[i][j]=='X')
            {
                up[i][j] = 0;
                lf[i][j] = 0;
            }   
            else
            {
                up[i][j] = up[i-1][j]+1;
                lf[i][j] = lf[i][j-1]+1;
            }
        }
    }
    for (int i=h ; i>=1 ; i--)
    {
        for (int j=w ; j>=1 ; j--)
        {
            if (v[i][j]=='X')
            {
                down[i][j] = 0;
                rg[i][j] = 0;
            }   
            else
            {
                down[i][j] = down[i+1][j]+1;
                rg[i][j] = rg[i][j+1]+1;
            }
        }
    }
    dfs(b+1, c+1);
    if (vis[e1][e2])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll tt = 1;
    // cin>>tt;
    while (tt--)
    {
        solve();
    }
    return 0;
}
 

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'bool check(long long int, long long int, long long int, long long int)':
Main.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
   57 | }
      | ^
#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...