Submission #1249924

#TimeUsernameProblemLanguageResultExecution timeMemory
1249924cpsbd66World Map (IOI25_worldmap)C++20
Compilation error
0 ms0 KiB
#include <vector>
using namespace std;

// signature expected by the grader:
vector<vector<int>> create_map(int N, int M,
                               const vector<int>& A,
                               const vector<int>& B) {
    // detect subtask 1: exact path 1–2–…–N
    bool isPath = (M == N-1);
    if (isPath) {
        for (int i = 0; i < M; i++) {
            if (!(A[i] == i+1 && B[i] == i+2)) {
                isPath = false;
                break;
            }
        }
    }
    if (isPath) {
        // K = N, identity coloring
        int K = N;
        vector<vector<int>> C(K, vector<int>(K));
        for (int i = 0; i < K; i++)
            for (int j = 0; j < K; j++)
                C[i][j] = i+1;
        return C;
    }

    // subtask 2: any tree (M = N-1)
    int K = N + M;
    vector<vector<int>> C(K, vector<int>(K));
    // first N columns = identity
    for (int i = 0; i < K; i++)
        for (int j = 0; j < N; j++)
            C[i][j] = i+1;

    // one column per edge
    for (int e = 0; e < M; e++) {
        int u = A[e]-1, v = B[e]-1;
        int col = N + e;
        // default each row i → color i+1
        for (int i = 0; i < K; i++)
            C[i][col] = (i < N ? i+1 : 1);
        // swap just the two rows
        C[u][col] = v+1;
        C[v][col] = u+1;
    }
    return C;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cckmgOQD.o: in function `main':
grader.cpp:(.text.startup+0x635): undefined reference to `create_map(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status