답안 #984294

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
984294 2024-05-16T12:47:17 Z IUA_Hasin 사이버랜드 (APIO23_cyberland) C++17
0 / 100
23 ms 16980 KB
#include "cyberland.h"
#include <bits/stdc++.h>
 
#define endl                                "\n"
#define yeap                                cout<<"YES"<<endl
#define nope                                cout<<"NO"<<endl
#define ll                                  long long
#define ld                                  long double
 
using namespace std; 

const ll N = 3e5+5;
const ll INF = 1e9+5;

vector<pair<ll, ll>> graph[N];
vector<ll> dist(N, INF);
ll vis[N];

void dijkstra(ll source){
    set<pair<ll, ll>> s;
    s.insert({0, source});
    dist[source] = 0;

    while(s.size()>0){
        auto node = *s.begin();
        ll v = node.second;
        ll v_dist = node.first;
        s.erase(s.begin());
        if(vis[v]==0){
            for(auto child : graph[v]){
                ll v2 = child.first;
                ll wt = child.second;
                if((dist[v]+wt)<(dist[v2])){
                    dist[v2] = dist[v]+wt;
                    s.insert({dist[v2], v2});
                }
            }
            vis[v] = 1;
        }
    }
    
}

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) {
    for(int i=0; i<=N; i++){
        graph[i].clear();
        vis[i] = 0;
        dist[i] = INF;
    }

    for(int i=0; i<x.size(); i++){
        ll a = x[i];
        ll b = y[i];
        ll wt = c[i];
        graph[a].push_back({b, wt});
        graph[b].push_back({a, wt});

    }

    dijkstra(0);
    ld ans = dist[H];
    // for(int i=0; i<N; i++){
    //     cout << dist[i] << " ";
    // }
    // cout<<endl;
    return ans;
}   

Compilation message

cyberland.cpp: In function 'void dijkstra(long long int)':
cyberland.cpp:27:12: warning: unused variable 'v_dist' [-Wunused-variable]
   27 |         ll v_dist = node.first;
      |            ^~~~~~
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:51:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i=0; i<x.size(); i++){
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 10332 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 10844 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 10844 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 16980 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 10840 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 11100 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 11096 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 11236 KB Wrong Answer.
2 Halted 0 ms 0 KB -