Submission #874718

# Submission time Handle Problem Language Result Execution time Memory
874718 2023-11-17T16:40:52 Z Itamar Cyberland (APIO23_cyberland) C++17
0 / 100
210 ms 24396 KB
#include <vector>
using namespace std;
#define vi vector<int>
#define pi pair<int,int>
#define x first
#define y second
#include "cyberland.h"
#define pd pair<double,double>
#define pdi pair<double,int>
#define vd vector<double>
#include <vector>
#include <queue>

void dfs(vector<bool>&vis, int i, int H,vector<vector<pdi>>&fr) {
    if (i ==H)return;
    if (vis[i])return;
    vis[i] = 1;
    for (pdi p : fr[i]) {
        dfs(vis, p.y, H, fr);
    }
}

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) {
    K = min(K, 69);
    vector<vd> dp(N, vd(K + 2,1e15));
    vector<vector<pdi>> fr(N);
    for (int i = 0; i < M; i++) {
        fr[X[i]].push_back({ c[i],Y[i] });
        fr[Y[i]].push_back({ c[i],X[i] });
    }
    priority_queue<pair<int,pdi>> pq;
    vi fre;
    vector<bool> vis(N);
    dfs(vis, 0,H,fr);
    pq.push({ 0,{0,0} });
    for (int i = 0; i < N; i++)if (vis[i] == 1 && arr[i] == 0)pq.push({ 0,{0,i} });

    while (!pq.empty()) {
        pair<int, pdi> q = pq.top();
        int s = q.x;
        pdi p = q.y;
        pq.pop();
        if ((- s) > K)continue;
        if (dp[p.y][-s] < -p.x)continue;
        dp[p.y][-s] = -p.x;
        if (p.y == H)continue;
        for (pd f : fr[p.y]) {
            if(arr[p.y]==2)pq.push({ s - 1,{p.x / 2 - f.x,f.y} });
            if(f.x-p.x <= dp[-s][f.y])pq.push({ s,{p.x - f.x,f.y} });
        }
    }
    double mini = 1e15;
    for (int i = 0; i <= K; i++)mini = min(mini, dp[H][i]);
    if(mini==1e15)return -1;
    return mini;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 924 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 860 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 24396 KB Correct.
2 Runtime error 45 ms 1364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 856 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1116 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 205 ms 1524 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 210 ms 1620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -