답안 #968320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968320 2024-04-23T10:01:03 Z Syrius 사이버랜드 (APIO23_cyberland) C++17
68 / 100
1163 ms 154424 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 ll inf = 1e18 + 9;
const int mxn = 2e5 + 2;
const int mod = 1e9 + 7;
 
vector < vector < pint > > adj(mxn);
vint arr_;
double dis[32][mxn];
bool vis[mxn];

priority_queue < pint > q[32];

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 (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]) {
                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]);
    }

    return (ans == inf) ? -1 : ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 52828 KB Correct.
2 Correct 24 ms 52992 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 53340 KB Correct.
2 Correct 33 ms 53588 KB Correct.
3 Correct 31 ms 53328 KB Correct.
4 Correct 33 ms 53532 KB Correct.
5 Correct 32 ms 53584 KB Correct.
6 Correct 30 ms 54068 KB Correct.
7 Correct 37 ms 54352 KB Correct.
8 Correct 21 ms 54608 KB Correct.
9 Correct 30 ms 53080 KB Correct.
10 Correct 30 ms 53084 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 53332 KB Correct.
2 Correct 35 ms 53332 KB Correct.
3 Correct 33 ms 53436 KB Correct.
4 Correct 33 ms 53076 KB Correct.
5 Correct 32 ms 53340 KB Correct.
6 Correct 16 ms 53580 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 187 ms 67432 KB Correct.
2 Correct 204 ms 54612 KB Correct.
3 Correct 176 ms 54228 KB Correct.
4 Correct 192 ms 54480 KB Correct.
5 Correct 100 ms 53732 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 53328 KB Correct.
2 Correct 31 ms 53584 KB Correct.
3 Correct 30 ms 53588 KB Correct.
4 Correct 33 ms 55000 KB Correct.
5 Correct 26 ms 53040 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 53580 KB Correct.
2 Correct 29 ms 53332 KB Correct.
3 Correct 40 ms 63060 KB Correct.
4 Correct 27 ms 54320 KB Correct.
5 Correct 29 ms 53188 KB Correct.
6 Correct 31 ms 53560 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Correct 375 ms 55660 KB Correct.
2 Correct 60 ms 7496 KB Correct.
3 Correct 685 ms 46992 KB Correct.
4 Correct 414 ms 31228 KB Correct.
5 Correct 1163 ms 115668 KB Correct.
6 Correct 1087 ms 154424 KB Correct.
7 Correct 416 ms 55888 KB Correct.
8 Incorrect 336 ms 55048 KB Wrong Answer.
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 52 ms 109904 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -