Submission #880350

#TimeUsernameProblemLanguageResultExecution timeMemory
880350Mardonbekhazratov사이버랜드 (APIO23_cyberland)C++17
15 / 100
26 ms7504 KiB
#include "cyberland.h" #include<bits/stdc++.h> #include <vector> using namespace std; #define ll long long const ll INF=1e18; vector<vector<pair<int,int>>>v; vector<bool>v1,v2; void dfs(int x){ v1[x]=true; for(auto [y,z]:v[x]){ if(!v1[y]) dfs(y); } } void dfss(int x){ v2[x]=true; for(auto [y,z]:v[x]){ if(!v2[y]) dfs(y); } } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { // bool subtask=true; // for(int i=0;i<N;i++) if(arr[i]!=1) subtask=false; // if(subtask){ v.assign(N,vector<pair<int,int>>(0)); for(int i=0;i<M;i++){ v[x[i]].push_back({y[i],c[i]}); v[y[i]].push_back({x[i],c[i]}); } vector<bool>vis(N,0); v1.assign(N,0); v2.assign(N,0); dfs(0); dfss(H); ll ans=INF; for(int i=0;i<N;i++){ if(i==0||(arr[i]==0&&v1[i]&&v2[i])){ priority_queue<pair<ll,int>>q; vector<ll>dp(N,INF); dp[i]=0; q.push({0,i}); while(!q.empty()){ int x=q.top().second; q.pop(); if(vis[x]) continue; vis[x]=true; for(auto [z,y]:v[x]){ if(dp[x]+y<dp[z]){ dp[z]=dp[x]+y; q.push({-dp[z],z}); } } } ans=min(ans,dp[H]); } } if(ans==INF) return -1.0; return 1.0*ans; //} }
#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...