Submission #981895

#TimeUsernameProblemLanguageResultExecution timeMemory
981895FZ_MeloCyberland (APIO23_cyberland)C++17
15 / 100
32 ms7004 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; struct tpos{ int node; double cnt; }; bool operator < (const tpos &a, const tpos &b){ return a.cnt>b.cnt; } struct ari{ int node; double cnt; }; vector<vector<ari>> adj; int state[100000]; priority_queue<tpos> q; int n, m, k, fin; double memo[100000]; double ans; void dfs(){ tpos t; while(!q.empty()){ t=q.top(); q.pop(); if(memo[t.node]!=-1 && memo[t.node]<=t.cnt) continue; memo[t.node]=t.cnt; for(auto h: adj[t.node]){ if(state[t.node]==0) q.push({h.node, h.cnt}); else q.push({h.node, t.cnt+h.cnt}); } } } 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; fin=H; adj.clear(); adj.resize(n); ans=-1; for(int i=0; i<m; i++){ adj[x[i]].push_back({y[i], (double)c[i]}); adj[y[i]].push_back({x[i], (double)c[i]}); } for(int i=0; i<n; i++){ state[i]=arr[i]; memo[i]=-1; } for(auto h: adj[0]){ q.push({h.node, h.cnt}); } memo[0]=0; dfs(); return memo[fin]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...