Submission #874704

# Submission time Handle Problem Language Result Execution time Memory
874704 2023-11-17T16:30:21 Z Itamar Cyberland (APIO23_cyberland) C++17
15 / 100
1533 ms 25128 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 (pd 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, 100);
    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()) {
        int s = pq.top().x;
        pdi p = pq.top().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} });
            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 Incorrect 23 ms 856 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1504 KB Correct.
2 Correct 35 ms 1616 KB Correct.
3 Correct 34 ms 1488 KB Correct.
4 Correct 32 ms 1648 KB Correct.
5 Correct 35 ms 1632 KB Correct.
6 Correct 39 ms 5016 KB Correct.
7 Correct 39 ms 5028 KB Correct.
8 Correct 19 ms 8800 KB Correct.
9 Correct 28 ms 1124 KB Correct.
10 Correct 29 ms 1124 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1564 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 253 ms 25128 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 868 KB Correct.
2 Correct 30 ms 868 KB Correct.
3 Correct 30 ms 864 KB Correct.
4 Correct 30 ms 4228 KB Correct.
5 Correct 29 ms 1372 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 1628 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 485 ms 1664 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1533 ms 2444 KB Wrong Answer.
2 Halted 0 ms 0 KB -