답안 #252905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252905 2020-07-26T12:29:33 Z Erkhemkhuu 무지개나라 (APIO17_rainbow) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int sN = 105;
char grid[sN][sN];
void init(int R, int C, int sr, int sc, int M, char *S) {
    int n, m, curx, cury, sz, i, j;
    string path;
    n = R; m = C; curx = sr; cury = sc;
    sz = M; path = S;
    for(i = 0; i <= n; i++)
        for(j = 0; j <= m; j++)
            grid[i][j] = '0';
    for(i = 0; i < sz; i++) {
        if(path[i] == 'N') grid[--curx][cury] = 'X';
        if(path[i] == 'E') grid[curx][++cury] = 'X';
        if(path[i] == 'S') grid[++curx][cury] = 'X';
        if(path[i] == 'W') grid[curx][--cury] = 'X';
    }
    return;
}
int colours(int ar, int ac, int br, int bc) {
    int x0, y0, x1, y1;
    x0 = ar; y0 = ac;
    x1 = br; y1 = bc;
    int N = x1 - x0 + 1;
    int M = y1 - y0 + 1;
    int i, j;
    char temp[sN][sN];
    for(i = x0; i <= x1; i++)
        for(j = y0; j <= y1; j++)
            temp[i - x0 + 1][j - y0 + 1] = grid[i][j];
    int cnt = 0;
    for(i = 1; i <= N; i++) {
        for(j = 1; j <= M; j++) {
            if(temp[i][j] == '0') {
                cnt++;
                queue <int> q;
                q.push(i * 1000 + j);
                while(!q.empty()) {
                    int v = q.front();
                    int curx = v / 1000;
                    int cury = v % 1000;
                    q.pop();
                    temp[curx][cury] = 'M';
                    if(curx - 1 >= 1 && temp[curx - 1][cury] == '0') q.push((curx - 1) * 1000 + cury);
                    if(cury + 1 <= M && temp[curx][cury + 1] == '0') q.push(curx * 1000 + cury + 1);
                    if(curx + 1 <= N && temp[curx + 1][cury] == '0') q.push((curx + 1) * 1000 + cury);
                    if(cury - 1 >= 1 && temp[curx][cury - 1] == '0') q.push(curx * 1000 + cury - 1);
                }
            }
        }
    }
    return cnt;
}

Compilation message

/tmp/ccNYtP8X.o: In function `main':
grader.cpp:(.text.startup+0x131): undefined reference to `colour(int, int, int, int)'
collect2: error: ld returned 1 exit status