Submission #923908

#TimeUsernameProblemLanguageResultExecution timeMemory
923908Darren0724Escape Route (JOI21_escape_route)C++17
0 / 100
9059 ms155076 KiB
#include "escape_route.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; const long long INF=1e18; vector<long long> calculate_necessary_time(int n, int m, long long s, int q, vector<int> a, vector<int> b,vector<long long> l, vector<long long> c, vector<int> u,vector<int> v, vector<long long> t) { vector<int> adj[n+1]; for(int i=0;i<m;i++){ adj[a[i]].push_back(i); adj[b[i]].push_back(i); } vector<vector<long long>> dis(n,vector<long long>(n,INF)),dis1(n,vector<long long>(n,-1)); for(int i=0;i<n;i++){ dis1[i][i]=s; priority_queue<pair<int,int>> pq; pq.push({s,i}); while(pq.size()){ auto [d,k]=pq.top(); pq.pop(); if(dis1[i][k]!=d)continue; for(int j:adj[k]){ int to=(a[j]==k?b[j]:a[j]); int cost=min(c[j]-l[j],dis1[i][k]-l[j]); if(dis1[i][to]<cost){ dis1[i][to]=cost; pq.push({cost,to}); } } } } for(int i=0;i<n;i++){ dis[i][i]=0; priority_queue<pair<int,int>> pq; pq.push({0,i}); while(pq.size()){ auto [d,k]=pq.top(); pq.pop(); d=-d; if(dis[i][k]!=d)continue; for(int j:adj[k]){ int to=(a[j]==k?b[j]:a[j]); int d1=(d%s<=c[j]-l[j]?d:(d/s+1)*s); int cost=d1+l[j]; if(dis[i][to]>cost){ dis[i][to]=cost; pq.push({-cost,to}); } } } } vector<long long> ans1(q); for(int i=0;i<q;i++){ long long a1=u[i],b1=v[i],t1=t[i]; long long ans=INF; fill(dis[a1].begin(),dis[a1].end(),INF); dis[a1][a1]=t1; priority_queue<pair<int,int>> pq; pq.push({-t1,a1}); while(pq.size()){ auto [d,k]=pq.top(); pq.pop(); d=-d; if(dis[a1][k]!=d)continue; for(int j:adj[k]){ int to=(a[j]==k?b[j]:a[j]); int d1=(d%s<=c[j]-l[j]?d:(d/s+1)*s); int cost=d1+l[j]; if(dis[a1][to]>cost){ dis[a1][to]=cost; pq.push({-cost,to}); } } } ans1[i]=dis[a1][b1]-t1; } return ans1; }

Compilation message (stderr)

escape_route.cpp: In function 'std::vector<long long int> calculate_necessary_time(int, int, long long int, int, std::vector<int>, std::vector<int>, std::vector<long long int>, std::vector<long long int>, std::vector<int>, std::vector<int>, std::vector<long long int>)':
escape_route.cpp:54:19: warning: unused variable 'ans' [-Wunused-variable]
   54 |         long long ans=INF;
      |                   ^~~
#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...