Submission #968349

# Submission time Handle Problem Language Result Execution time Memory
968349 2024-04-23T10:31:04 Z Syrius Cyberland (APIO23_cyberland) C++17
68 / 100
589 ms 105732 KB
#include <bits/stdc++.h>
#include "cyberland.h"
using namespace std;
 
// #define int long long
#define ll long long
#define ff first
#define ss second
#define pint pair < double , int >
#define vint vector < int >
#define fast ios_base::sync_with_stdio(NULL); cin.tie(NULL)
 
const double inf = 1e18 + 9;
const int mxn = 2e5 + 2;
const int mod = 1e9 + 7;
 
vector < vector < pint > > adj(mxn);
vint arr_;
double dis[35][mxn];
bool vis[mxn];

priority_queue < pint > q[35];

void dfs(int x , int par , int H) {
    if (vis[x]) return;
    vis[x] = 1;
    if (x == H) return;
    if (arr_[x] == 0) {
        // q[0].push({0 , x});
        for (int i = 0; i <= 30; i++) {
            q[i].push({0 , x});
        }
    }
    for (pint i : adj[x]) {
        if (i.ss == par) continue;
        dfs(i.ss , x , H);
    }
}
 
double solve(int n , int m , int k , int H , vint x , vint y , vint c , vint arr) {

    for (int i = 0; i < n; i++) {
        adj[i].clear();
        vis[i] = 0;
    }

    for (int i = 0; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            dis[i][j] = -1;
        }
    }

    arr_ = arr;
    for (int i = 0; i < m; i++) {
        adj[x[i]].push_back({c[i] , y[i]});
        adj[y[i]].push_back({c[i] , x[i]});
    }

    dfs(0 , 0 , H);
    q[0].push({0 , 0});

    for (int i = 0; i <= k; i++) {
        while (!q[i].empty()) {
            pint p = q[i].top();
            q[i].pop();
            
            if (dis[i][p.ss] != -1) continue;
            dis[i][p.ss] = -p.ff;
            if (p.ss == H) continue;

            for (pint j : adj[p.ss]) {
                if (arr[j.ss] == 0) continue;
                q[i].push({p.ff - j.ff , j.ss});
                if (arr[j.ss] == 2) q[i+1].push({(p.ff - j.ff) / 2 , j.ss});
            }
        }
    }

    double ans = inf;
    for (int i = 0; i <= k; i++) {
        if (dis[i][H] != -1) ans = min(ans , dis[i][H]);
    }

    if (ans == inf) return -1;
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 20 ms 5824 KB Correct.
2 Correct 20 ms 5772 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 26 ms 6492 KB Correct.
2 Correct 29 ms 6740 KB Correct.
3 Correct 29 ms 6552 KB Correct.
4 Correct 32 ms 6892 KB Correct.
5 Correct 31 ms 6748 KB Correct.
6 Correct 29 ms 9560 KB Correct.
7 Correct 47 ms 9812 KB Correct.
8 Correct 18 ms 12380 KB Correct.
9 Correct 25 ms 6232 KB Correct.
10 Correct 30 ms 6224 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 200 ms 7084 KB Correct.
2 Correct 183 ms 7104 KB Correct.
3 Correct 160 ms 6996 KB Correct.
4 Correct 81 ms 6604 KB Correct.
5 Correct 82 ms 6220 KB Correct.
6 Correct 55 ms 10332 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 173 ms 70096 KB Correct.
2 Correct 189 ms 42344 KB Correct.
3 Correct 185 ms 40112 KB Correct.
4 Correct 166 ms 36312 KB Correct.
5 Correct 82 ms 37352 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 27 ms 37200 KB Correct.
2 Correct 38 ms 37344 KB Correct.
3 Correct 37 ms 27220 KB Correct.
4 Correct 31 ms 24020 KB Correct.
5 Correct 23 ms 20568 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 138 ms 17560 KB Correct.
2 Correct 111 ms 15536 KB Correct.
3 Correct 41 ms 38480 KB Correct.
4 Correct 130 ms 21956 KB Correct.
5 Correct 65 ms 14560 KB Correct.
6 Correct 126 ms 33636 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 305 ms 54804 KB Correct.
2 Correct 57 ms 52236 KB Correct.
3 Correct 589 ms 49292 KB Correct.
4 Incorrect 444 ms 50040 KB Wrong Answer.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 51 ms 105732 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -