hiho week 232 register

Ended

Participants:110

Verdict:Accepted
Score:100 / 100
Submitted:2018-12-10 11:23:03

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;
const int maxn = 505;
int n, m;
string G[maxn];
int vis[maxn][maxn];
int up, down, Left, Right;
int dir[4][2] = {{0,1}, {1,0}, {-1,0}, {0,-1}};
bool judge(int x, int y) {
    if (x >= 0 && x < n && y >= 0 && y < m && G[x][y] == '1' && !vis[x][y]) {
        return true;
    }
    return false;
}
void dfs(int x, int y, vector<pair<int,int>>& res) {
    vis[x][y] = 1;
    for (int i = 0; i < 4; ++i) {
        int dx = x + dir[i][0];
        int dy = y + dir[i][1];
        if (judge(dx, dy)) {
            if (dx < up) up = dx;
            if (dx > down) down = dx;
            if (dy > Right) Right = dy;
            if (dy < Left) Left = dy;
            res.push_back(make_pair(dx,dy));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX