답안 #783866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783866 2023-07-15T11:34:13 Z ZHIRDILBILDIZ 사이버랜드 (APIO23_cyberland) C++17
0 / 100
331 ms 8376 KB
#include<bits/stdc++.h>
#include"cyberland.h"
#define ld double
#define ll long long
#define fi first
#define se second
using namespace std ;
const int N = 1e5 ;
bitset<N> us ;
ld dist[N] ;
vector<pair<int, ll>> v[N] ;
ld deikstra_for_one(int start, int abu)
{
    for(int i = 0 ; i < N ; i++)
        dist[i] = 1e18 ;
    set<pair<ld, int>> s ;
    dist[start] = 0 ;
    s.insert({0, start}) ;
    while(s.size())
    {
        pair<ld, int> p = *s.begin() ;
        s.erase(p) ;
        if(us[p.se])
            continue ;
        us[p.se] = 1 ;
        for(auto i : v[p.se])
        {
            if(us[i.fi] || dist[i.fi] <= p.fi + i.se)
                continue ;
            dist[i.fi] = dist[p.se] + i.se ;
            s.insert({dist[i.fi], i.fi}) ;
        }
    }
    return dist[abu] ;
}
ld solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr)
{
    bool flag1 = 0 ;
    for(int i = 0 ; i < n ; i++)
        if(arr[i] != 1)flag1 = 1 ;
    for(int i = 0 ; i < m ; i++)
    {
        v[x[i]].push_back({y[i], c[i]}) ;
        v[y[i]].push_back({x[i], c[i]}) ;
    }
    if(!flag1)
    {
        ld num = deikstra_for_one(0, h) ;
        if(num == 1e18)return -1 ;
        else return num ;
    }
}
//signed main()
//{
//    ios_base::sync_with_stdio( 0 ) ;
//    cin.tie( 0 ) ;
//    cout.tie( 0 ) ;
//    int n, m, k, h ;
//    cin >> n >> m >> k >> h ;
//    vector<int> a(m), b(m), c(m), arr(n) ;
//    for(int i = 0 ; i < n ; i++)
//        cin >> arr[i] ;
//    for(int i = 0 ; i < m ; i++)
//        cin >> a[i] >> b[i] >> c[i] ;
//    cout << solve(n, m, k, h, a, b, c, arr) ;
//    return 0 ;
//}
//14 13 30 4
//1 1 1 1 1 1 1 1 1 1 1 1 1 1
//0 1 2
//0 2 1
//2 4 100
//1 9 3
//1 3 1
//9 5 4
//9 6 5
//6 7 7
//6 8 1
//8 13 9
//13 10 10
//13 11 11
//13 12 12

Compilation message

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 331 ms 4240 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 5860 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 6328 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 8376 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 6220 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 6372 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 6200 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 6184 KB Wrong Answer.
2 Halted 0 ms 0 KB -