hiho week 159 register

Ended

Participants:533

Verdict:Accepted
Score:100 / 100
Submitted:2017-07-20 09:53:55

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 = 110;
const double EPS = 1e-6;
int N, M, x, y;
int pic[MAXN][MAXN];
bool visited[MAXN][MAXN];
vector<pair<int, int> > locs;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool isN(pair<int, int> &a, pair<int, int> &b) {
    if ((abs(a.first - b.first) == 1 && abs(a.second - b.second) == 0) ||
    (abs(a.first - b.first) == 0 && abs(a.second - b.second) == 1)){
        return true;
    }
    return false;
}
void dfs(int row, int col, int &cnt, int val) {
    visited[row][col] = true;
    cnt += 4;
    pair<int, int> pp = make_pair(row, col);
    for (int i = 0; i < locs.size(); i++) {
        if (isN(locs[i], pp)) {cnt -= 2;}
     }
    locs.push_back(pp);
    for(int i = 0; i < 4; i++) {
        int new_x = row + dx[i];
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX