Submission #900178

# Submission time Handle Problem Language Result Execution time Memory
900178 2024-01-07T20:21:58 Z vjudge1 Land of the Rainbow Gold (APIO17_rainbow) C++17
Compilation error
0 ms 0 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, string s){
    rows = R;
    cols = C;
    sr--, sc--;
    ii pos = {sr, sc};
    grid[pos.first][pos.second] = 1;
    for(char c : s){
        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 colours(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;
}

Compilation message

/usr/bin/ld: /tmp/cc60J1yE.o: in function `main':
grader.cpp:(.text.startup+0xed): undefined reference to `init(int, int, int, int, int, char*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x167): undefined reference to `colour(int, int, int, int)'
collect2: error: ld returned 1 exit status