답안 #984731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
984731 2024-05-17T03:48:41 Z Faisal_Saqib 사이버랜드 (APIO23_cyberland) C++17
0 / 100
1563 ms 2097152 KB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
vector<pair<int,int>> adj[N];
double ans=0;
int WANT;
void dfs(int v,int p=-1,double dis=0)
{
    if(v==WANT)
    {
        ans=dis;
    }
    for(auto [u,w]:adj[v])
    {
        if(u!=p)
        {
            dfs(u,v,dis+w);
        }
    }
}
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    WANT=h;
    if(m==(n-1))
    {
        //We have a Tree
        bool all_one=1;
        for(auto i:arr)
            all_one&=(i==1);
        for(int j=0;j<m;j++)
        {
            adj[x[j]].push_back({y[j],c[j]});
            adj[y[j]].push_back({x[j],c[j]});
        }
        if(all_one)
        {
            // this is easy
            // just calculate the distance between 0 and h
            dfs(0);
            return ans;
        }
        else{

        }

    }
    return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1563 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1218 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 4956 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 6460 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 3676 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 3872 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 3676 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 3676 KB Wrong Answer.
2 Halted 0 ms 0 KB -