Submission #1202234

#TimeUsernameProblemLanguageResultExecution timeMemory
1202234rafsanamin2020Cyberland (APIO23_cyberland)C++20
0 / 100
13 ms2116 KiB
#include "cyberland.h"

#include <vector>
#include <iostream>

using namespace std;

// subtask 1

double ac(int k, int f)
{
    // cout << k << " " << f;
    if (f == 0)
    {
        return 0;
    }
    else if (f == 2)
    {
        return (double)k / (double)2;
    }
    else
    {
        return (double)f;
    }
};

int _(int k)
{
    return k == 2 ? 1 : 2;
}

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)
{
    vector<vector<double>> C(3, vector<double>(3, (double)(1E9 + 5)));
    vector<vector<bool>> V(3, vector<bool>(3, false));

    for (int i = 0; i < M; i++)
    {
        C[x[i]][y[i]] = (double)c[i];
        C[y[i]][x[i]] = (double)c[i];
        V[x[i]][y[i]] = true;
        V[y[i]][x[i]] = true;
    }

    if ((!V[0][H] && !V[0][_(H)]) || (!V[0][H] && !V[H][_(H)]))
    {
        return -1;
    }

    return min(ac(C[0][_(H)], arr[_(H)]) + C[_(H)][H], C[0][(H)]);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...