제출 #954013

#제출 시각아이디문제언어결과실행 시간메모리
954013OtalpCyberland (APIO23_cyberland)C++17
0 / 100
1051 ms71764 KiB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pb push_back
#define ff first
#define ss second


vector<pair<int, int>> q[200100];
double dp[200100][35];
int us[200100][35];
int pos[200100];

void dfs(int v){
    pos[v] = 1;
    for(int i=0; i<q[v].size(); i++){
        int to = q[v][i].ff;
        if(pos[to]) continue;
        dfs(to);
    }
}



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<m; i++){
        q[x[i]].pb({y[i], c[i]});
        q[y[i]].pb({x[i], c[i]});
    }
    dfs(0);
    
    set<pair<double, pii>> s;
    s.insert({0, {0, 0}});

    for(int i=0; i<n; i++){
        if(arr[i] == 0 and pos[i] == 1){
            s.insert({0, {i, 0}});
        }
    }

    while(s.size()){
        auto it = s.begin();
        if(us[it -> ss.ff][it -> ss.ss]){
            s.erase(it);
            continue;
        }
        int v = it -> ss.ff;
        int c = it -> ss.ss;
        us[v][c] = 1;
        dp[v][c] = it -> ff;
        if(v == h) continue;
        for(int i=0; i<q[v].size(); i++){
            int to = q[v][i].ff;
            int x = q[v][i].ss;
            if(!us[to][c]){
                s.insert({dp[v][c] + x, {to, c}});
            }
            if(arr[to] == 2 and c + 1 <= K and !us[to][c+1]){
                s.insert({(dp[v][c] + x) / 2, {to, c + 1}});
            }
        }
    }
    double mn=1e18;
    for(int i=0; i<=K; i++){
        if(us[h][i]) mn = min(mn, dp[h][i]);
    }
    if(mn == 1e18) return -1;
    return mn;
}


컴파일 시 표준 에러 (stderr) 메시지

cyberland.cpp: In function 'void dfs(int)':
cyberland.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0; i<q[v].size(); i++){
      |                  ~^~~~~~~~~~~~
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(int i=0; i<q[v].size(); i++){
      |                      ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...