hiho week 236 register

Ended

Participants:103

Verdict:Accepted
Score:100 / 100
Submitted:2019-01-11 18:11:38

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
queue<pair<pair<int,int>,int> > que;
string s;
int ans[1000][1000],n,m,dx[]={0,0,-1,1},dy[]={-1,1,0,0};
int ok(int x,int y){
    if(x>=1&&x<=n&&y>=1&&y<=m&&ans[x][y]==-1)
        return 1;
    return 0;
}
int main(void) {
    long long i,j;
    scanf("%d %d",&n,&m);
    memset(ans,-1,sizeof(ans));
    for(i=0;i<n;i++){
        cin>>s;
        for(j=0;j<m;j++){
            if(s[j]=='0'){
                ans[i+1][j+1]=0;
                que.push(make_pair(make_pair(i+1,j+1),0));
            }
        }
    }
    while(que.size()){
        auto t=que.front();
        que.pop();
        for(i=0;i<4;i++){
            auto T=make_pair( make_pair((t.first).first+dx[i],(t.first).second+dy[i]), t.second+1);
            if(ok(T.first.first,T.first.second)){
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX