Submission #792587

#TimeUsernameProblemLanguageResultExecution timeMemory
792587WarinchaiCyberland (APIO23_cyberland)C++17
68 / 100
3071 ms39224 KiB
#include "cyberland.h" #include<bits/stdc++.h> using namespace std; vector<pair<int,int> >v[100005]; priority_queue<pair<double,pair<int,int> >,vector<pair<double,pair<int,int> > >,greater<pair<double,pair<int,int> > > >pq; double dis[100005][35]; double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { for(int i=0;i<=n;i++){ for(int j=0;j<=30;j++){ dis[i][j]=LLONG_MAX; } v[i].clear(); } for(int i=0;i<m;i++){ int st=x[i]; int en=y[i]; int cost=c[i]; v[st].push_back({en,cost}); v[en].push_back({st,cost}); } dis[0][0]=0; pq.push({0,{0,0}}); while(!pq.empty()){ int node=pq.top().second.first; int used=pq.top().second.second; double cost=pq.top().first; pq.pop(); if(node==h){ continue; } for(int i=0;i<v[node].size();i++){ int nx=v[node][i].first; double ed=v[node][i].second; if(arr[nx]==2){ double nxu=(cost+ed)/2; double nxd=cost+ed; if(nxu<dis[nx][used+1]){ dis[nx][used+1]=nxu; pq.push({nxu,{nx,used+1}}); } if(nxd<dis[nx][used]){ dis[nx][used]=nxd; pq.push({nxd,{nx,used}}); } }else if(arr[nx]==0){ if(dis[nx][used]>0){ dis[nx][used]=0; pq.push({0,{nx,used}}); } }else{ if(cost+ed<dis[nx][used]){ dis[nx][used]=cost+ed; pq.push({cost+ed,{nx,used}}); } } } } double ans=LLONG_MAX; for(int i=0;i<=30;i++){ ans=min(ans,dis[h][i]); } if(ans!=LLONG_MAX){ return ans; }else{ return -1; } //return -1; }

Compilation message (stderr)

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=0;i<v[node].size();i++){
      |                     ~^~~~~~~~~~~~~~~
#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...