Submission #1131121

#TimeUsernameProblemLanguageResultExecution timeMemory
1131121AnhPhamCyberland (APIO23_cyberland)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
// #ifdef ONLINE_JUDGE
#include "cyberland.h"
// #endif

using namespace std;

#define int     long long
#define sz(v)   (int)(v).size()
#define all(v)  (v).begin(), (v).end()

const   int     MOD = (int)1e9 + 7;
const   int     INF = (int)1e18 + 18;

// void solve();

// int32_t main() {
// #define CODE1 ""
//     if (fopen(CODE1".inp", "r"))
//         freopen(CODE1".inp", "r", stdin), freopen(CODE1".out", "w", stdout);

// #define CODE2 ""
//     if (fopen(CODE2".inp", "r"))
//         freopen(CODE2".inp", "r", stdin), freopen(CODE2".out", "w", stdout);

//     cin.tie(nullptr), cout.tie(nullptr) -> sync_with_stdio(false);
//     int testcases = 1;

// #define multitest 0
//     if (multitest) { cin >> testcases; } for (; testcases--;) { solve(); }
// }

/** [Pham Hung Anh - 12I - Tran Hung Dao High School for Gifted Student] **/
/**                            The Last Dance                            **/

struct EDGE {
    int x, y, c;
};

int N, M, K, H;
vector <EDGE> edge;
vector <int> A;

namespace sub1 {
    bool check_condition() {
        return N <= 3 && K <= 30;
    }

    double solve() {
        if (N == 1)
            return 0.0;
        else {
            vector <vector <double>> cost(N, vector <double> (N, INF));
            for (auto [u, v, c] : edge)
                cost[u][v] = cost[v][u] = c;

            if (N == 2)
                return (cost[0][H] >= INF ? -1 : cost[0][H]);
            else {
                double ret = cost[0][H];
                int other = 3 - H;
                if (cost[0][other] >= INF && cost[other][H] >= INF)
                    return -1.0;
                else {
                    if (A[other] == 0)
                        ret = min(ret, cost[other][H]);
                    else if (A[other] == 1)
                        ret = min(ret, cost[0][other] + cost[other][H]);
                    else {
                        if (K >= 1)
                            ret = min(ret, cost[0][other] / 2.0 + cost[other][H]);
                        else
                            ret = min(ret, cost[0][other] + cost[other][H]);
                    }
                }

                return ret;
            }
        }
    }
}

double solve(int n, int m, int k, int h, std::vector <int> X, std::vector <int> Y, std::vector <int> C, std::vector <int> arr) {
    N = n, M = m, K = k, H = h;
    A = arr;
    for (int i = 0; i < M; ++i)
        edge.push_back({ X[i], Y[i], C[i] });
    
    if (sub1 :: check_condition())
        return sub1 :: solve();
    
    return 0.0;
} 

// void solve() {
//     cin >> N >> M >> K >> H;

//     edge = vector <EDGE> (M);
//     for (auto &[x, y, c] : edge)
//         cin >> x >> y >> c;

//     A = vector <int> (N);
//     for (int &a : A)
//         cin >> a;

//     if (sub1 :: check_condition())
//         sub1 :: solve();
// }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccSdufJk.o: in function `main':
grader.cpp:(.text.startup+0x71e): 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