Submission #755965

# Submission time Handle Problem Language Result Execution time Memory
755965 2023-06-10T18:47:01 Z HaciyevAlik Cyberland (APIO23_cyberland) C++17
37 / 100
882 ms 8780 KB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
const int mx=1e5+5;
int n,m,h,k,used[mx];
long dis[mx];
vector<pair<int,int>> g[mx];
void dfs(int u) {
    used[u]=1;
    for(int i=0;i<int(g[u].size());++i) {
        int v=g[u][i].ff;
        if(!used[v]&&v!=h) dfs(v);
    }
}
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    n=N,m=M,h=H,k=K;
    for(int i=0;i<mx;++i) g[i].clear();
    memset(used,0,sizeof(used));
    for(int i=0;i<m;++i) {
        g[x[i]].pb({y[i],c[i]});
        g[y[i]].pb({x[i],c[i]});
    }
    set<int> s;
    dfs(0);
    for(int i=0;i<n;++i) {
        if(used[i]&&!arr[i]) s.insert(i);
    }
    memset(used,0,sizeof(used));
    priority_queue<pair<int,int>> pq;
    for(int i=0;i<n;++i) dis[i]=1e10;
    for(auto i:s) {
        pq.push({0,i});
        dis[i]=0;
    }
    pq.push({0,0});
    dis[0]=0;
    while(!pq.empty()) {
        int u=pq.top().ss; pq.pop();
        if(used[u]) continue;
        used[u]=1;
        for(int i=0;i<int(g[u].size());++i) {
            int v=g[u][i].ff,w=g[u][i].ss;
            if(dis[u]+w<dis[v]) {
                dis[v]=dis[u]+w;
                pq.push({-dis[v],v});
            }
        }
    }
    if(!used[h]) {
        return -1;
    } else {
        return dis[h];
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 882 ms 3172 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3140 KB Correct.
2 Correct 33 ms 3156 KB Correct.
3 Correct 33 ms 3276 KB Correct.
4 Correct 35 ms 3152 KB Correct.
5 Correct 34 ms 3204 KB Correct.
6 Correct 23 ms 3804 KB Correct.
7 Correct 29 ms 3712 KB Correct.
8 Correct 14 ms 4496 KB Correct.
9 Correct 130 ms 3100 KB Correct.
10 Correct 133 ms 3096 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 38 ms 3140 KB Correct.
2 Correct 38 ms 3156 KB Correct.
3 Correct 38 ms 3184 KB Correct.
4 Correct 121 ms 3096 KB Correct.
5 Correct 118 ms 3100 KB Correct.
6 Correct 7 ms 3796 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 8088 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 3236 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 38 ms 3260 KB Correct.
2 Correct 34 ms 3272 KB Correct.
3 Correct 43 ms 8780 KB Correct.
4 Correct 19 ms 4052 KB Correct.
5 Correct 114 ms 3096 KB Correct.
6 Correct 35 ms 3216 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 3156 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 3232 KB Wrong Answer.
2 Halted 0 ms 0 KB -