Submission #870761

#TimeUsernameProblemLanguageResultExecution timeMemory
870761daniel920712Escape Route (JOI21_escape_route)C++17
5 / 100
9035 ms111956 KiB
#include "escape_route.h" #include <queue> #include <utility> #include <stdio.h> #define ll long long using namespace std; struct aaa { ll a,b,c; }; priority_queue < pair < ll , ll > , vector < pair < ll , ll > >, greater < pair < ll , ll > > > dij; vector < long long > Ans; pair < long long , long long > DP[105][105]; vector < aaa > Next[105]; ll vis[105]; pair < ll, ll > operator +(pair < ll , ll > a, pair < ll , ll > b) { b.first+=a.first; if(b.second==0) b.second=a.second; else if(a.second&&b.second) b.first++; return b; } 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) { //printf("aaaaa\n"); ll i,j,k,a,b,c; pair < ll , ll > ans; aaa tt; for(i=0;i<M;i++) { tt.a=B[i]; tt.b=L[i]; tt.c=C[i]; Next[A[i]].push_back(tt); tt.a=A[i]; Next[B[i]].push_back(tt); } for(i=0;i<N;i++) for(j=0;j<N;j++) DP[i][j]=make_pair(100,0); for(i=0;i<N;i++) { DP[i][i]=make_pair(0,0); vis[i]=-1; } for(i=0;i<N;i++) { dij.push(make_pair(0,i)); while(!dij.empty()) { auto xx=dij.top(); dij.pop(); a=xx.first; b=xx.second; if(vis[b]==i) continue; vis[b]=i; DP[i][b]=make_pair(0,a); for(auto j:Next[b]) if(a+j.b<=j.c) dij.push(make_pair(a+j.b,j.a)); } } for(k=0;k<N;k++) for(i=0;i<N;i++) for(j=0;j<N;j++) DP[i][j]=min(DP[i][j],DP[i][k]+DP[k][j]); for(i=0;i<N;i++) vis[i]=-1; for(i=0;i<Q;i++) { ans=make_pair(100,0); dij.push(make_pair(T[i],U[i])); while(!dij.empty()) { auto xx=dij.top(); dij.pop(); a=xx.first; b=xx.second; //printf("%lld %lld %lld\n",a,b,vis[b]); if(vis[b]==i) continue; vis[b]=i; //printf("bb %lld %lld %lld %lld\n",b,a,DP[b][V[i]].first,DP[b][V[i]].second); //if(b==V[i]) ans=min(ans,make_pair((ll) 0,a)); ans=min(ans,make_pair(0,a)+DP[b][V[i]]); for(auto j:Next[b]) if(a+j.b<=j.c) dij.push(make_pair(a+j.b,j.a)); } //printf("aa %lld %lld %lld\n",ans.first,ans.second,T[i]); Ans.push_back(ans.first*S+ans.second-T[i]); //`printf("aa %lld\n",Ans[i]); } return Ans; }

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:27:18: warning: unused variable 'c' [-Wunused-variable]
   27 |     ll i,j,k,a,b,c;
      |                  ^
#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...