Rating changes for the last round are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
44337946 Practice:
DDullahan
1064D - 52 GNU C++11 Accepted 374 ms 8148 KB 2018-10-15 02:56:56 2018-10-15 02:56:56
 
 
→ Source
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long long ll;

#define __m int mid=(l+r)>>1
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1 

template<class T>
inline bool rd(T &num) {
    char in;bool IsN = false;
    while(in = getchar(), in != '-' && (in < '0' || in > '9'))if(in == EOF)return false;
    in == '-' ? (IsN = true, num = 0) : num = in - '0';
    while(in = getchar(), in >= '0' && in <= '9')num = num * 10 + in - '0';
    return IsN ? num = -num : num, true;
}
template<class T, class S>
inline bool rd(T &num1, S &num2){return rd(num1)&&rd(num2);}
template<class T, class S, class Z>
inline bool rd(T &num1, S &num2, Z &num3){return rd(num1)&&rd(num2)&&rd(num3);}
template<class T>
inline void _wr(T num){if(num>9)_wr(num/10);putchar('0'+num%10);}
template<class T>
inline void wt(T num){if(num<0)putchar('-'),num=-num;_wr(num);}

string nico;
#ifdef LOCAL
#define debug(x) cout<<'['<<#x<<"]:"<<(x)<<endl
#define infile(x) freopen(x,"r",stdin)
#define outfile(x) freopen(x,"w",stdout)
#else
#define debug(x)
#define infile(x)
#define outfile(x)
#endif

#define rep(a,b,c) for(register int (a)=(b);(a)<(c);++(a))
#define per(a,b,c) for(register int (a)=(b);(a)>=(c);--(a))
#define none(a) memset(a,-1,sizeof(a))
#define clr(a) memset(a,0,sizeof(a))
#define inf(a) memset(a,0x3f,sizeof(a))
#define IO ios::sync_with_stdio(false)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define space putchar(' ')
#define enter puts("")
#define endl '\n'
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define lowbit(x) (x&-x)

const int maxn = 2000+7;
const int inf  = 0x3f3f3f3f;
const int mod  = 1e9 + 7;
const int none = -1;
const LL linf  = (LL)inf << 32 | inf;

int n,m;
int sx,sy,l,r;
bool Map[maxn][maxn];
bool ans[maxn][maxn];
char now[maxn];
int step[4][2]={
    0,1,0,-1,1,0,-1,0
};
struct p{
    int x,y,l,r;
    void fill(int a,int b,int c,int d){
        x=a;y=b;l=c;r=d;
    }
    bool friend operator <(const p a,const p b){
        return a.l+a.r > b.l+b.r;
    }
};
void bfs(int nowx,int nowy){
    p now;
    now.fill(sx,sy,0,0);
    priority_queue<p>Q;
    ans[sx][sy]=true;
    Q.push(now);
    while(!Q.empty()){
        now=Q.top();Q.pop();
        rep(i,0,4){
            int nextx=now.x+step[i][0],nexty=now.y+step[i][1];
            int nextl=now.l+(i==1),nextr=now.r+(i==0);
            if(nextx<1||nextx>n||nexty<1||nexty>m||!Map[nextx][nexty])             
                continue;
            if(nextl>l||nextr>r)continue;
            if(!ans[nextx][nexty]){
                ans[nextx][nexty]=true;
                p temp;
                temp.fill(nextx,nexty,nextl,nextr);
                Q.push(temp);
            }
        }
    }
}
int main(){
    rd(n,m);
    rd(sx,sy);
    rd(l,r);
    rep(i,1,n+1){
        scanf("%s",now);
        rep(j,0,m){
            if(now[j]=='.')
                Map[i][j+1]=true;
        }
    }
    bfs(sx,sy);
    int oo=0;
    rep(i,1,n+1)
        rep(j,1,m+1)
            oo+=ans[i][j];
    printf("%d\n",oo);

}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details