Submission #908772

#TimeUsernameProblemLanguageResultExecution timeMemory
908772alexander707070Escape Route (JOI21_escape_route)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "escape_route.h" #define MAXN 107 using namespace std; const long long inf=1e17; struct edge{ int to; long long l,c; }; int n,m,qs,minv,from,to; long long s,w,ans; vector<long long> sol; int a[MAXN],b[MAXN]; long long l[MAXN],c[MAXN]; long long dist[MAXN][MAXN],dst[MAXN]; vector<edge> v[MAXN]; int li[MAXN],tim; priority_queue< pair<long long,int> , vector< pair<long long,int> > , greater< pair<long long,int> > > q; void dijkstra(int x){ for(int i=1;i<=n;i++){ dist[x][i]=inf; } dist[x][x]=0; tim++; q.push({0,x}); while(!q.empty()){ minv=q.top().second; q.pop(); if(li[minv]==tim)continue; li[minv]=tim; for(int i=0;i<v[minv].size();i++){ if(li[v[minv][i].to]==tim or dist[x][v[minv][i].to]<=dist[x][minv]+v[minv][i].l or dist[x][minv]>v[minv][i].c-v[minv][i].l)continue; dist[x][v[minv][i].to]=dist[x][minv]+v[minv][i].l; q.push({dist[x][v[minv][i].to],v[minv][i].to}); } } } void query(int x,long long t){ for(int i=1;i<=n;i++){ dst[i]=inf; } dst[x]=t; tim++; q.push({t,x}); while(!q.empty()){ minv=q.top().second; q.pop(); if(li[minv]==tim)continue; li[minv]=tim; for(int i=0;i<v[minv].size();i++){ if(li[v[minv][i].to]==tim or dst[v[minv][i].to]<=dst[minv]+v[minv][i].l or dst[minv]>v[minv][i].c-v[minv][i].l)continue; dst[v[minv][i].to]=dst[minv]+v[minv][i].l; q.push({dst[v[minv][i].to],v[minv][i].to}); } } } bool u[MAXN][MAXN][MAXN]; long long dp[MAXN][MAXN][MAXN]; long long ff(int x,int y,int day){ if(x==y)return 0; if(day>n)return inf; if(u[x][y][day])return dp[x][y][day]; u[x][y][day]=true; dp[x][y][day]=inf; for(int p=1;p<=n;p++){ if(dist[x][p]!=inf){ if(p!=y){ dp[x][y][day]=min(dp[x][y][day],ff(p,y,day+1)+s); }else{ dp[x][y][day]=min(dp[x][y][day],ff(p,y,day+1)+dist[x][y]); } } } return dp[x][y][day]; } 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){ n=N; m=M; s=S; q=Q; for(int i=1;i<=m;i++){ a[i]=A[i-1]; b[i]=B[i-1]; l[i]=L[i-1]; c[i]=C[i-1]; a[i]++; b[i]++; v[a[i]].push_back({b[i],l[i],c[i]}); v[b[i]].push_back({a[i],l[i],c[i]}); } for(int i=1;i<=n;i++){ dijkstra(i); } for(int i=1;i<=qs;i++){ from=U[i-1]; to=V[i-1]; w=T[i-1]; from++; to++; query(from,w); ans=inf; for(int f=1;f<=n;f++){ if(dst[f]!=inf){ if(f!=to)ans=min(ans,s+ff(f,to,0)); else ans=min(ans,dst[to]); } } sol.push_back(ans-w); } return sol; }

Compilation message (stderr)

escape_route.cpp: In function 'void dijkstra(int)':
escape_route.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<edge>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i=0;i<v[minv].size();i++){
      |                     ~^~~~~~~~~~~~~~~
escape_route.cpp: In function 'void query(int, long long int)':
escape_route.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<edge>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int i=0;i<v[minv].size();i++){
      |                     ~^~~~~~~~~~~~~~~
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:95:22: error: no match for 'operator=' (operand types are 'std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >' and 'int')
   95 |     n=N; m=M; s=S; q=Q;
      |                      ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from escape_route.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:456:11: note: candidate: 'std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >& std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >::operator=(const std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >&)'
  456 |     class priority_queue
      |           ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:456:11: note:   no known conversion for argument 1 from 'int' to 'const std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >&'
/usr/include/c++/10/bits/stl_queue.h:456:11: note: candidate: 'std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >& std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >::operator=(std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >&&)'
/usr/include/c++/10/bits/stl_queue.h:456:11: note:   no known conversion for argument 1 from 'int' to 'std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >&&'