Submission #973565

# Submission time Handle Problem Language Result Execution time Memory
973565 2024-05-02T07:22:17 Z SuPythony Cyberland (APIO23_cyberland) C++17
21 / 100
1399 ms 2097152 KB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
vector<vector<pair<int,int>>> al;
vector<int> nodes;
 
void dfs(int u, int p, int H, vector<int> &a) {
    if (u==H) return;
    if (a[u]==0||u==0) nodes.push_back(u);
    for (auto v: al[u]) {
        if (v.first==p) continue;
        dfs(v.first,u,H,a);
    }
}
 
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> a) {
    al.assign(N+1,vector<pair<int,int>>());
    nodes.clear();
    for (int i=0; i<M; i++) {
        al[x[i]].push_back({y[i],c[i]});
        al[y[i]].push_back({x[i],c[i]});
    }
    dfs(0,-1,H,a);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
    vector<ll> dist(N+1,1e18);
    dist[N]=0;
    q.push({0,N});
    for (int i: nodes) {
        al[N].push_back({i,0});
        al[i].push_back({N,0});
    }
    while (!q.empty()) {
        int u=q.top().second; q.pop();
        for (auto v: al[u]) {
            if (dist[u]+v.second<dist[v.first]) {
                dist[v.first]=dist[u]+v.second;
                q.push({dist[v.first],v.first});
            }
        }
    }
    if (dist[H]==1e18) return -1;
    return (double)dist[H];
}
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 604 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 604 KB Correct.
2 Correct 20 ms 604 KB Correct.
3 Correct 20 ms 588 KB Correct.
4 Correct 20 ms 604 KB Correct.
5 Correct 20 ms 604 KB Correct.
6 Correct 19 ms 1628 KB Correct.
7 Correct 24 ms 1372 KB Correct.
8 Correct 11 ms 2396 KB Correct.
9 Correct 19 ms 484 KB Correct.
10 Correct 18 ms 516 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 22 ms 600 KB Correct.
2 Correct 22 ms 1508 KB Correct.
3 Correct 21 ms 1512 KB Correct.
4 Correct 21 ms 1372 KB Correct.
5 Correct 22 ms 1368 KB Correct.
6 Correct 5 ms 1628 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 6996 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1399 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1263 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1223 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1253 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -