제출 #1310341

#제출 시각아이디문제언어결과실행 시간메모리
1310341beluga_cat축제 (IOI25_festival)C++20
컴파일 에러
0 ms0 KiB
#include "festival.h"
#include <vector>
#include <numeric>

using namespace std;

// Function to be implemented for the contest
vector<vector<int>> solve(int N, int M, vector<int> U, vector<int> V) {
    // 1. Build adjacency list
    vector<vector<int>> adj(N + 1);
    for (int i = 0; i < M; ++i) {
        adj[U[i]].push_back(V[i]);
        adj[V[i]].push_back(U[i]);
    }

    // 2. Generate a sequence that visits all nodes/edges
    vector<int> path;
    vector<bool> visited(N + 1, false);
    
    auto dfs = [&](auto self, int u) -> void {
        visited[u] = true;
        path.push_back(u);
        for (int v : adj[u]) {
            if (!visited[v]) {
                self(self, v);
                path.push_back(u); // Backtrack
            }
        }
    };
    dfs(dfs, 1);

    // 3. Map this path to a grid
    int S = path.size();
    vector<vector<int>> grid(S, vector<int>(S));
    for (int i = 0; i < S; ++i) {
        for (int j = 0; j < S; ++j) {
            // Simplest mapping: row i belongs to path[i]
            grid[i][j] = path[i];
        }
    }

    return grid;
}

컴파일 시 표준 에러 (stderr) 메시지

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