Submission #21296881


Source Code Expand

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}

void solve(){
    int h,w,x,y;
    cin>>h>>w>>x>>y;--x,--y;
    vector<string> s(h);
    for(auto&c:s) cin>>c;
    int ans{1};
    for(int i{x-1};i>=0;--i){
        if(s[i][y]=='#') break;
        ++ans;
    }
    for(int i{x+1};i<h;++i){
        if(s[i][y]=='#') break;
        ++ans;
    }
    for(int j{y-1};j>=0;--j){
        if(s[x][j]=='#') break;
        ++ans;
    }
    for(int j{y+1};j<w;++j){
        if(s[x][j]=='#') break;
        ++ans;
    }
    cout<<ans<<'\n';
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
}

Submission Info

Submission Time
Task B - Visibility
User Motsu_xe
Language C++ (GCC 9.2.1)
Score 200
Code Size 898 Byte
Status AC
Exec Time 8 ms
Memory 3708 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 32
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All extreme_00.txt, extreme_01.txt, extreme_02.txt, extreme_03.txt, extreme_04.txt, extreme_05.txt, extreme_06.txt, extreme_07.txt, handmade_00.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
extreme_00.txt AC 8 ms 3672 KiB
extreme_01.txt AC 2 ms 3560 KiB
extreme_02.txt AC 3 ms 3668 KiB
extreme_03.txt AC 3 ms 3628 KiB
extreme_04.txt AC 2 ms 3668 KiB
extreme_05.txt AC 2 ms 3656 KiB
extreme_06.txt AC 2 ms 3624 KiB
extreme_07.txt AC 2 ms 3672 KiB
handmade_00.txt AC 2 ms 3644 KiB
random_00.txt AC 2 ms 3620 KiB
random_01.txt AC 2 ms 3652 KiB
random_02.txt AC 4 ms 3620 KiB
random_03.txt AC 3 ms 3708 KiB
random_04.txt AC 2 ms 3636 KiB
random_05.txt AC 4 ms 3672 KiB
random_06.txt AC 2 ms 3624 KiB
random_07.txt AC 3 ms 3556 KiB
random_08.txt AC 4 ms 3700 KiB
random_09.txt AC 2 ms 3640 KiB
random_10.txt AC 2 ms 3552 KiB
random_11.txt AC 2 ms 3660 KiB
random_12.txt AC 2 ms 3620 KiB
random_13.txt AC 2 ms 3612 KiB
random_14.txt AC 3 ms 3612 KiB
random_15.txt AC 3 ms 3564 KiB
random_16.txt AC 3 ms 3656 KiB
random_17.txt AC 2 ms 3652 KiB
random_18.txt AC 2 ms 3688 KiB
random_19.txt AC 2 ms 3700 KiB
sample_01.txt AC 3 ms 3604 KiB
sample_02.txt AC 2 ms 3604 KiB
sample_03.txt AC 3 ms 3532 KiB