Submission #983921

# Submission time Handle Problem Language Result Execution time Memory
983921 2024-05-16T08:02:10 Z hariaakas646 Cyberland (APIO23_cyberland) C++17
49 / 100
860 ms 2097152 KB
#include "cyberland.h"
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;


vector<vii> graph;
vb vis;

void dfs(int x) {
    if(vis[x]) return;
    vis[x] = true;
    for(auto e : graph[x]) dfs(e.f);
}

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) {
    graph = vector<vii>(n);
    frange(i, m) {
        int a=x[i];int b = y[i];
        if(a != h) graph[a].pb(mp(b, c[i]));
        if(b != h) graph[b].pb(mp(a, c[i]));
    }
    vis = vb(n);
    dfs(0);
    vector<vector<ld>> dist(k+1, vector<ld>(n, 1e18));
    vector<vb> vis2(k+1, vb(n));
    dist[0][0] = 0;
    priority_queue<pair<ld, pii>> pq;
    pq.push(mp(0, mp(0, 0)));
    forr(i, 1, n) {
        if(vis[i] && arr[i] == 0) {
            dist[0][i] = 0;
            pq.push(mp(0, mp(i, 0)));
        }
    }

    while(pq.size()) {
        auto p = pq.top();
        pq.pop();
        int x = p.s.f;
        int c = p.s.s;
        ld w = -p.f;
        if(vis2[c][x]) continue;
        vis2[c][x] = true;

        for(auto e : graph[x]) {
            if(dist[c][e.f] > w + e.s) {
                dist[c][e.f] = w + e.s;
                pq.push(mp(-dist[c][e.f], mp(e.f, c)));
            }
            if(c<k && arr[e.f]==2 && dist[c+1][e.f] > (w+e.s)/2) {
                dist[c+1][e.f] = (w+e.s)/2;
                pq.push(mp(-dist[c+1][e.f], mp(e.f, c+1)));
            }
        }
    }

    ld mi = 1e18;
    frange(i, k+1) mi = min(mi, dist[i][h]);
    if(abs(mi-1e18)<=1) return -1;
    else
    return mi;


}
# Verdict Execution time Memory Grader output
1 Correct 44 ms 592 KB Correct.
2 Correct 45 ms 868 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1112 KB Correct.
2 Correct 31 ms 1060 KB Correct.
3 Correct 30 ms 1048 KB Correct.
4 Correct 32 ms 1292 KB Correct.
5 Correct 31 ms 1044 KB Correct.
6 Correct 28 ms 6100 KB Correct.
7 Correct 37 ms 5992 KB Correct.
8 Correct 16 ms 12120 KB Correct.
9 Correct 27 ms 604 KB Correct.
10 Correct 28 ms 604 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 32 ms 996 KB Correct.
2 Correct 32 ms 2016 KB Correct.
3 Correct 31 ms 1356 KB Correct.
4 Correct 31 ms 1628 KB Correct.
5 Correct 37 ms 1420 KB Correct.
6 Correct 7 ms 5468 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 188 ms 40904 KB Correct.
2 Incorrect 203 ms 2300 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1264 KB Correct.
2 Correct 30 ms 1052 KB Correct.
3 Correct 28 ms 1084 KB Correct.
4 Correct 28 ms 6120 KB Correct.
5 Correct 25 ms 604 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1116 KB Correct.
2 Correct 26 ms 1908 KB Correct.
3 Correct 49 ms 47196 KB Correct.
4 Correct 20 ms 4672 KB Correct.
5 Correct 28 ms 1628 KB Correct.
6 Correct 27 ms 2020 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 241 ms 2228 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 860 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -