답안 #750465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750465 2023-05-29T14:26:11 Z Gurban 사이버랜드 (APIO23_cyberland) C++17
8 / 100
47 ms 7784 KB
#include "cyberland.h"
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

const double inf = 1e16;
const int maxn=1e5+5;
const double eps = 0.00000001;
int D[maxn];
vector<pair<int,double>>E[maxn];

double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    for(int i = 0;i < N;i++) E[i].clear();
    for(int i = 0;i < M;i++){
        E[x[i]].push_back({y[i],c[i]});
        E[y[i]].push_back({x[i],c[i]});
    }
    // for(int i = 1;i < N;i++) D[i] = 1e9;
    // D[0] = 0;
    // deque<int>deq;
    // vector<bool>vis(N);
    // deq.push_back(0);
    // while(!deq.empty()){
    //     int x = deq.front();
    //     deq.pop_front();
    //     if(vis[x]) continue;
    //     vis[x] = 1;
    //     for(auto i : E[x]){
    //         if(D[x] + (arr[i.first] == 2) < D[i.first]){
    //             D[i.first] = D[x] + (arr[i.first] == 2);
    //             if(arr[i.first] != 2) deq.push_front(i.first);
    //             else deq.push_back(i.first);
    //         }
    //     }
    // }
    vector<int>zeros = {0};
    // vector<int>two;
    for(int i = 1;i < N;i++) if(arr[i] == 0) zeros.push_back(i);
    // for(int i = 1;i < N;i++) if(arr[i] == 2) two.push_back(i);
    
    priority_queue<pair<ll,int>>q;
    q.push({0,H});

    ll ans = inf;
    // double der = 1;

    for(int i = 0;i <= 0;i++){
        vector<ll>dis(N,inf);
        dis[H] = 0;
        vector<bool>vis(N,0);
        while(!q.empty()){
            
            int x = q.top().second;
            ll len = -q.top().first;
            q.pop();

            if(vis[x]) continue;
            vis[x] = 1;

            for(auto j : E[x]){
                ll now = j.second + dis[x];
                if(dis[j.first] > now){
                    dis[j.first] = now;
                    q.push({-now,j.first}); 
                }
            }
        }
        for(auto j : zeros) ans = min(ans,dis[j]);
        // for(auto j : two) if(abs(dis[j] - inf) >= eps) q.push({-dis[j],j});
        // der *= 2;
    }
    // if(abs(ans - inf) < eps) return -1;
    return ans;
}

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:57:16: warning: unused variable 'len' [-Wunused-variable]
   57 |             ll len = -q.top().first;
      |                ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 2772 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2840 KB Correct.
2 Correct 23 ms 2772 KB Correct.
3 Correct 23 ms 2788 KB Correct.
4 Correct 23 ms 2772 KB Correct.
5 Correct 28 ms 2848 KB Correct.
6 Correct 22 ms 3640 KB Correct.
7 Correct 26 ms 3668 KB Correct.
8 Correct 16 ms 4500 KB Correct.
9 Correct 24 ms 2720 KB Correct.
10 Correct 26 ms 2736 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 2756 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 7784 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 2900 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 2900 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 2900 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 2932 KB Wrong Answer.
2 Halted 0 ms 0 KB -