답안 #57256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57256 2018-07-14T12:07:56 Z gabrielsimoes 무지개나라 (APIO17_rainbow) C++17
11 / 100
3000 ms 1844 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;

const int MAX = 55;

int dr[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};

int R, C;
bitset<MAX> land[MAX];

void init(int _R, int _C, int sr, int sc, int M, char *S) {
    R = _R; C = _C;
    for (int r = 1; r <= R; r++)
        for (int c = 1; c <= C; c++)
            land[r][c] = true;

    land[sr][sc] = false;
    for (int i = 0; i < M; i++) {
        int d = 0;
        switch(S[i]) {
            case 'N': d = 0; break;
            case 'E': d = 1; break;
            case 'S': d = 2; break;
            case 'W': d = 3; break;
        }
        sr += dr[d];
        sc += dc[d];
        land[sr][sc] = false;
    }
}

int color[MAX][MAX], _color = 0;
void dfs_1(int r, int c, int ar, int ac, int br, int bc) {
    for (int d = 0; d < 4; d++) {
        int nr = r + dr[d], nc = c + dc[d];
        if (r >= ar && r <= br && c >= ac && c <= bc && land[nr][nc] && color[nr][nc] == 0) {
            color[nr][nc] = color[r][c];
            dfs_1(nr, nc, ar, ac, br, bc);
        }
    }
}


int colour(int ar, int ac, int br, int bc) {
    for (int r = ar; r <= br; r++)
        for (int c = ac; c <= bc; c++)
            color[r][c] = 0;
    _color= 0;

    for (int r = ar; r <= br; r++) {
        for (int c = ac; c <= bc; c++) {
            if (land[r][c] && color[r][c] == 0) {
                color[r][c] = ++_color;
                dfs_1(r, c, ar, ac, br, bc);
            }
        }
    }

    return _color;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 9 ms 512 KB Output is correct
3 Correct 22 ms 640 KB Output is correct
4 Correct 23 ms 680 KB Output is correct
5 Correct 8 ms 836 KB Output is correct
6 Correct 2 ms 836 KB Output is correct
7 Correct 2 ms 836 KB Output is correct
8 Correct 3 ms 836 KB Output is correct
9 Correct 2 ms 836 KB Output is correct
10 Correct 2 ms 836 KB Output is correct
11 Correct 30 ms 904 KB Output is correct
12 Correct 18 ms 996 KB Output is correct
13 Correct 13 ms 996 KB Output is correct
14 Correct 10 ms 996 KB Output is correct
15 Correct 2 ms 996 KB Output is correct
16 Correct 3 ms 996 KB Output is correct
17 Correct 3 ms 996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 996 KB Output is correct
2 Correct 3 ms 996 KB Output is correct
3 Runtime error 5 ms 1376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 996 KB Output is correct
2 Execution timed out 3029 ms 1532 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 9 ms 512 KB Output is correct
3 Correct 22 ms 640 KB Output is correct
4 Correct 23 ms 680 KB Output is correct
5 Correct 8 ms 836 KB Output is correct
6 Correct 2 ms 836 KB Output is correct
7 Correct 2 ms 836 KB Output is correct
8 Correct 3 ms 836 KB Output is correct
9 Correct 2 ms 836 KB Output is correct
10 Correct 2 ms 836 KB Output is correct
11 Correct 30 ms 904 KB Output is correct
12 Correct 18 ms 996 KB Output is correct
13 Correct 13 ms 996 KB Output is correct
14 Correct 10 ms 996 KB Output is correct
15 Correct 2 ms 996 KB Output is correct
16 Correct 3 ms 996 KB Output is correct
17 Correct 3 ms 996 KB Output is correct
18 Runtime error 5 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 9 ms 512 KB Output is correct
3 Correct 22 ms 640 KB Output is correct
4 Correct 23 ms 680 KB Output is correct
5 Correct 8 ms 836 KB Output is correct
6 Correct 2 ms 836 KB Output is correct
7 Correct 2 ms 836 KB Output is correct
8 Correct 3 ms 836 KB Output is correct
9 Correct 2 ms 836 KB Output is correct
10 Correct 2 ms 836 KB Output is correct
11 Correct 30 ms 904 KB Output is correct
12 Correct 18 ms 996 KB Output is correct
13 Correct 13 ms 996 KB Output is correct
14 Correct 10 ms 996 KB Output is correct
15 Correct 2 ms 996 KB Output is correct
16 Correct 3 ms 996 KB Output is correct
17 Correct 3 ms 996 KB Output is correct
18 Runtime error 5 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -