Submission #749957

# Submission time Handle Problem Language Result Execution time Memory
749957 2023-05-29T02:19:16 Z I_love_Hoang_Yen Cyberland (APIO23_cyberland) C++17
Compilation error
0 ms 0 KB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;

const int ZERO = 0;
const int NORMAL = 1;
const int DIV2 = 2;

double sub1(
        int n, int m, int maxDiv2, int target,
        const vector<int>& edge_froms,
        const vector<int>& edge_tos,
        const vector<int>& edge_costs,
        const vector<int>& node_types) {
    vector<vector<double>> costs(n, vector<double> (n, -1));
    for (int i = 0; i < m; ++i) {
        int u = edge_froms[i];
        int v = edge_tos[i];
        costs[u][v] = costs[v][u] = edge_costs[i];
    }

    // go directly from 0 -> target
    double res = costs[0][target];

    // go 0 -> other vertex -> target
    int other = 3 - target;
    switch (node_types[other]) {
        case NORMAL:
            res = min(res, costs[0][other] + costs[other][target]);
            break;
        case ZERO:
            res = min(res, costs[other][target]);
            break;
        case DIV2:
            res = min(res, costs[0][other] / 2.0 + costs[other][target]);
            break;
    }
    return res;
}

double solve(
        int n, int m, int maxDiv2, int target,
        const vector<int>& edge_froms,
        const vector<int>& edge_tos,
        const vector<int>& edge_costs,
        const vector<int>& node_types) {
    if (n == 3) {
        return sub1(
                n, m, maxDiv2, target,
                edge_froms, edge_tos, edge_costs, node_types);
    }
    return 0.0;
}

Compilation message

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