Submission #982013

# Submission time Handle Problem Language Result Execution time Memory
982013 2024-05-13T18:02:51 Z alo_54 Cyberland (APIO23_cyberland) C++17
8 / 100
24 ms 8380 KB
#include "cyberland.h"

#include <bits/stdc++.h>
using namespace std;

struct Arista
{
    int v, p;
};


struct Nodo
{
    vector <Arista> ady;
    int ability;

};

vector <Nodo> g;
vector <Arista> padre;
vector <bool> vis;
int h;

void clean(int N)
{
    g.clear();
    padre.clear();
    vis.clear();

    g.resize(N);
    padre.resize(N);
    vis.resize(N, false);
}

void dfs(int nodo)
{

    if (nodo == h)
    {
        return;
    }

    for (auto i : g[nodo].ady)
    {
        if (!vis[i.v])
        {
            padre[i.v] = {nodo, i.p};

            //cout<<"padre "<<i.v<<": "<<nodo<<" c: "<<i.p<<endl;
            vis[i.v] = true;
            dfs(i.v);
        }
        
    } 
}

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) 
{
    h = H;
    clean(N);

    for (int i = 0; i < M; i++)
    {
        g[x[i]].ady.push_back({y[i], c[i]});
        g[y[i]].ady.push_back({x[i], c[i]});
    }

    for (int i = 0; i < N; i++)
    {
        g[i].ability = arr[i];
    }

    vis[0] = true;

    padre[0] = {-1, 0};

    dfs(0);

    double cost = 0;

    int curr = H;

    while (curr != -1)
    {
        cost +=(double) padre[curr].p;
        curr =(double) padre[curr].v;
    }


    return (double)cost;

    

}
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 860 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1388 KB Correct.
2 Correct 19 ms 1628 KB Correct.
3 Correct 23 ms 1588 KB Correct.
4 Correct 18 ms 1612 KB Correct.
5 Correct 20 ms 1628 KB Correct.
6 Correct 15 ms 2400 KB Correct.
7 Correct 21 ms 2500 KB Correct.
8 Correct 8 ms 2908 KB Correct.
9 Correct 19 ms 1372 KB Correct.
10 Correct 17 ms 1372 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 1600 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 8380 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 1368 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 1396 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1440 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 660 KB Wrong Answer.
2 Halted 0 ms 0 KB -