Submission #955020

# Submission time Handle Problem Language Result Execution time Memory
955020 2024-03-29T07:48:16 Z Abito Cyberland (APIO23_cyberland) C++17
15 / 100
3000 ms 27996 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];
double dis[N][35];
vector<pair<int,int>> adj[N];
bool vis[N][35];
void dijkstra(){
    priority_queue<pair<double,pair<int,int>>> pq;
    pq.push({0,{0,0}});
    for (int i=0;i<n;i++) for (int j=0;j<=k;j++) dis[i][j]=-1;
    dis[0][0]=0;
    while (!pq.empty()){
        int x=pq.top().S.F,y=pq.top().S.S;
        pq.pop();
        if (vis[x][y]) continue;
        vis[x][y]=1;
        for (auto u:adj[x]){
            if (dis[u.F][y]<0 || dis[u.F][y]>dis[x][y]+double(u.S)){
                dis[u.F][y]=dis[x][y]+double(u.S);
                pq.push({-dis[u.F][y],{u.F,y}});
            }
            if (!a[u.F]){
                dis[u.F][y]=0;
                pq.push({0,{u.F,y}});
            }
            elif (a[u.F]==2 && y+1<=k){
                int nd=(dis[x][y]+double(u.S))/2.0;
                if (dis[u.F][y+1]<0 || dis[u.F][y+1]>nd){
                    dis[u.F][y+1]=nd;
                    pq.push({-nd,{u.F,y+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=K;
    for (int i=0;i<n;i++){
        adj[i].clear();
        for (int j=0;j<=k;j++) vis[i][j]=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];
    dijkstra();
    double ans=dis[H][0];
    for (int i=1;i<=k;i++){
        if (dis[H][i]<0) continue;
        ans=min(ans,dis[H][i]);
    }return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 4952 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 5468 KB Correct.
2 Correct 22 ms 5724 KB Correct.
3 Correct 20 ms 5700 KB Correct.
4 Correct 22 ms 5604 KB Correct.
5 Correct 21 ms 5572 KB Correct.
6 Correct 20 ms 12380 KB Correct.
7 Correct 25 ms 12680 KB Correct.
8 Correct 12 ms 14684 KB Correct.
9 Correct 21 ms 5460 KB Correct.
10 Correct 19 ms 5468 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 5468 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 27996 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 5468 KB Correct.
2 Correct 20 ms 5716 KB Correct.
3 Correct 20 ms 5724 KB Correct.
4 Correct 20 ms 12732 KB Correct.
5 Correct 17 ms 5212 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 5456 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 305 ms 5992 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3045 ms 16932 KB Time limit exceeded
2 Halted 0 ms 0 KB -