Submission #973382

# Submission time Handle Problem Language Result Execution time Memory
973382 2024-05-01T21:45:00 Z Abito Cyberland (APIO23_cyberland) C++17
15 / 100
504 ms 73864 KB
#include "cyberland.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define elif else if
#define pb push_back
using namespace std;
const int N=1e5+5;
int n,m,k,a[N],h;
double dis[N][95];
vector<pair<int,int>> adj[N];
bool vis[N][95];
vector<int> v;
void dfs(int x){
    if (!a[x] && x) v.pb(x);
    vis[x][94]=1;
    for (auto u:adj[x]){
        if (vis[u.F][94]) continue;
        dfs(u.F);
    }return;
}
void dijkstra(){
    priority_queue<pair<double,pair<int,int>>> pq;
    for (auto u:v) pq.push({0,{u,0}}),dis[u][0]=0;
    if (pq.empty()) pq.push({0,{0,0}}),dis[0][0]=0;
    while (!pq.empty()){
        int i=pq.top().S.F,j=pq.top().S.S;
        //cout<<i<<' '<<j<<endl;
        pq.pop();
        if (vis[i][j] || i==h) continue;
        vis[i][j]=1;
        for (auto u:adj[i]){
            if (dis[i][j]+u.S<dis[u.F][j] || dis[u.F][j]<0){
                dis[u.F][j]=dis[i][j]+u.S;
                pq.push({-dis[u.F][j],{u.F,j}});
            }
            if (a[u.F]==2){
                if ((dis[i][j]+u.S)/2.0<dis[u.F][j+1] || dis[u.F][j+1]<0){
                    dis[u.F][j+1]=(dis[i][j]+u.S)/2.0;
                    pq.push({-dis[u.F][j+1],{u.F,j+1}});
                }
            }
        }
    }return;
}
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) {
    n=N;m=M;k=min(K,90);v.clear();h=H;
    for (int i=0;i<n;i++){
        adj[i].clear();
        for (int j=0;j<=k;j++) vis[i][j]=0,dis[i][j]=-1;
        vis[i][94]=0;
    }
    for (int i=0;i<m;i++){
        adj[x[i]].pb({y[i],c[i]});
        adj[y[i]].pb({x[i],c[i]});
    }
    for (int i=0;i<n;i++) a[i]=arr[i];
    dfs(0);
    dijkstra();
    double ans=-1;
    for (int i=0;i<=k;i++) if (dis[H][i]>=0 && (ans==-1 || dis[H][i]<ans)) ans=dis[H][i];
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 7000 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 7688 KB Correct.
2 Correct 23 ms 7772 KB Correct.
3 Correct 28 ms 7764 KB Correct.
4 Correct 23 ms 7696 KB Correct.
5 Correct 23 ms 7760 KB Correct.
6 Correct 24 ms 18524 KB Correct.
7 Correct 28 ms 18776 KB Correct.
8 Correct 17 ms 24924 KB Correct.
9 Correct 21 ms 7516 KB Correct.
10 Correct 20 ms 7516 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 7844 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 504 ms 73864 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 8024 KB Correct.
2 Correct 21 ms 7768 KB Correct.
3 Correct 21 ms 7772 KB Correct.
4 Correct 23 ms 18780 KB Correct.
5 Correct 18 ms 7260 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 7776 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 8148 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 452 ms 9144 KB Wrong Answer.
2 Halted 0 ms 0 KB -