답안 #900180

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900180 2024-01-07T20:23:38 Z vjudge1 무지개나라 (APIO17_rainbow) C++17
11 / 100
15 ms 860 KB
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
#define ii pair<int,int>

const int N = 55;
int grid[N][N];
int rows, cols;

map<char,ii> to = {{'N', {-1, 0}}, {'S', {1, 0}}, {'W', {0, -1}}, {'E', {0, 1}}};

void init(int R, int C, int sr, int sc, int M, char *s){
    rows = R;
    cols = C;
    sr--, sc--;
    ii pos = {sr, sc};
    grid[pos.first][pos.second] = 1;
    for(int i=0; i<M; ++i){
        char c = s[i];
        pos.first += to[c].first;
        pos.second += to[c].second;
        grid[pos.first][pos.second] = 1;
    }
}

void clear(){
    for(int i=0; i<rows; ++i){
        for(int j=0; j<cols; ++j){
            if(grid[i][j] == 2) grid[i][j] = 0;
        }
    }
}

vector<ii> mov = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

void dfs(int i, int j, int ar, int ac, int br, int bc){
    for(auto tmp : mov){
        int ni = i + tmp.first;
        int nj = j + tmp.second;
        if(ni >= ar && ni <= br && nj >= ac && nj <= bc && grid[ni][nj] == 0){
            grid[ni][nj] = 2;
            dfs(ni, nj, ar, ac, br, bc);
        }
    }
}

int colour(int ar, int ac, int br, int bc){
    ar--, ac--;
    br--, bc--;
    int ans = 0;
    for(int i=ar; i<=br; ++i){
        for(int j=ac; j<=bc; ++j){
            if(grid[i][j] == 0){
                ans++;
                grid[i][j] = 2;
                dfs(i, j, ar, ac, br, bc);
            }
        }
    }
    clear();
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 6 ms 472 KB Output is correct
3 Correct 11 ms 600 KB Output is correct
4 Correct 15 ms 604 KB Output is correct
5 Correct 7 ms 348 KB Output is correct
6 Correct 0 ms 444 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 440 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 10 ms 604 KB Output is correct
12 Correct 9 ms 348 KB Output is correct
13 Correct 8 ms 552 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 2 ms 856 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 860 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 6 ms 472 KB Output is correct
3 Correct 11 ms 600 KB Output is correct
4 Correct 15 ms 604 KB Output is correct
5 Correct 7 ms 348 KB Output is correct
6 Correct 0 ms 444 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 440 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 10 ms 604 KB Output is correct
12 Correct 9 ms 348 KB Output is correct
13 Correct 8 ms 552 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Runtime error 1 ms 860 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 6 ms 472 KB Output is correct
3 Correct 11 ms 600 KB Output is correct
4 Correct 15 ms 604 KB Output is correct
5 Correct 7 ms 348 KB Output is correct
6 Correct 0 ms 444 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 440 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 10 ms 604 KB Output is correct
12 Correct 9 ms 348 KB Output is correct
13 Correct 8 ms 552 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Runtime error 1 ms 860 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -