hiho week 232 register

Ended

Participants:110

Verdict:Accepted
Score:100 / 100
Submitted:2018-12-10 20:28:19

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<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
char s[505][505];
int q[505][505] = {0};
int n,m;
int xx=10000,yy=10000;
int dx=-1,dy=-1;
void dfs(int a,int b)
{
    if( a<0 || b<0 || a >= n || b >= m || s[a][b] != '1' ||q[a][b]==1) {
        return;
    }
    s[a][b] = '.';
    q[a][b] = 1;
    if(b<yy) yy = b;
    if(a<xx) xx = a;
    if(a>dx) dx = a;
    if(b>dy) dy = b;
    dfs(a+1,b);
    dfs(a-1,b);
    dfs(a,b+1);
    dfs(a,b-1);
}
int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX