답안 #787623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787623 2023-07-19T10:29:49 Z aymanrs 사이버랜드 (APIO23_cyberland) C++17
8 / 100
946 ms 2097152 KB
#include <bits/stdc++.h>
using namespace std;
struct node {
    vector<pair<node*, int>> l;
    long long f = -1;
    bool g;
};
void gfs(node* n, node* p){
    for(auto [c, co] : n->l){
        if(c!=p){gfs(c, n);
        n->g |= c->g;}
    }
}
void dfs(node* n, node* p){
    for(auto [c, co] : n->l){
        if(c != p){
            c->f = n->f + co;
            dfs(c, n);
        }
    }
}
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){
    node g[N];
    g[0].g =true;
    for(int i = 0;i < M;i++){
        g[x[i]].l.emplace_back(&g[y[i]], c[i]);
        g[y[i]].l.emplace_back(&g[x[i]], c[i]);
    }
    g[H].f = 0;
    gfs(&g[H], NULL);
    for(auto [c, co] : g[H].l){
        if(c->g) {
            c->f = co;
            dfs(c, &g[H]);
        }
    }
    long long ans = g[0].f;
    for(int i = 0;i < N;i++){
        if(!arr[i] && g[i].f != -1) ans = min(ans, g[i].f);
    }
    return ans;
}
// int main(){
//     cout << solve(3, 2, 30, 2, {1, 2}, {2, 0}, {12, 4}, {1, 2, 1}) << '\n';
// }
# 결과 실행 시간 메모리 Grader output
1 Runtime error 885 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 820 KB Correct.
2 Correct 20 ms 1192 KB Correct.
3 Correct 19 ms 1180 KB Correct.
4 Correct 20 ms 1108 KB Correct.
5 Correct 20 ms 1260 KB Correct.
6 Correct 16 ms 2248 KB Correct.
7 Correct 21 ms 2124 KB Correct.
8 Correct 9 ms 3020 KB Correct.
9 Correct 19 ms 1000 KB Correct.
10 Correct 18 ms 1092 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 1092 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 9064 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 878 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 946 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 930 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 920 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -