hiho week 159 register

Ended

Participants:533

Verdict:Accepted
Score:100 / 100
Submitted:2017-07-17 22:06:43

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<cstdio>
int ans;
int Matrix[101][101];
bool visited[101][101];
void search(int start_x, int start_y, int N, int M) {
    int horizontal[4] = {-1, 1, 0, 0};
    int vertical[4] = {0, 0, 1, -1};
    int bias = 4;
    for (int i = 0; i < 4; i++) {
        int next_x = start_x + horizontal[i];
        int next_y = start_y + vertical[i];
        if ((next_x >= 0) && (next_x < N) && (next_y >= 0) && (next_y < M)) {
            if (Matrix[next_x][next_y] == Matrix[start_x][start_y]) {
                bias--;
            }
            if ((!visited[next_x][next_y]) && (Matrix[next_x][next_y] == Matrix[start_x][start_y])) {
                visited[next_x][next_y] = true;
                search(next_x, next_y, N, M);
            }
        }
    }
    ans += bias;
}
int main() {
    int N, M, x, y;
    scanf("%d %d %d %d", &N, &M, &x, &y);
    for (int i = 0; i < N; i++) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX