Submission #1093079

#TimeUsernameProblemLanguageResultExecution timeMemory
1093079Dennis_JasonOlympic Bus (JOI20_ho_t4)C++14
0 / 100
74 ms81416 KiB
#include <bits/stdc++.h> #define NMAX 201 #define MMAX 100 #define pb push_back #define eb emplace_back #define MOD 100003 #define nl '\n' #define INF 1e18 #define LLONG_MAX 9223372036854775807 #define pii pair<int,int> #define tpl tuple<int,int,int,int> //#pragma GCC optimize("O3") #define int long long //#define cin fin //#define cout fout using namespace std; ifstream fin("feast.in"); ofstream fout("feast.out"); /* * ================DEMONSTRATION=================== BAD IDEA:(( =====================END======================== */ int n,m; vector<vector<tpl>>G(NMAX); vector<vector<vector<int>>>dist_from_one(NMAX,vector<vector<int>>(MMAX,vector<int>(MMAX,INF))); vector<vector<vector<int>>>dist_from_n(NMAX,vector<vector<int>>(MMAX,vector<int>(MMAX,INF))); //dist[i][j][l]=distanta minima pana la nodul i nefolosind muchia j si cu muchia l inversata void dijkstra(int node,vector<vector<vector<int>>>&dist) { priority_queue<tpl,vector<tpl>,greater<tpl>>pq; dist[node][0][0]=0; for(int i=0;i<=m;++i) { pq.push({0,node,i,0}); } while(!pq.empty()) { auto [dis,first,j,l]=pq.top(); pq.pop(); for(auto [x,cost,inv,pos]:G[node]) { if(pos==j) continue; if(!l && inv) { if(dist[x][j][pos]>dist[first][j][l]+cost) { dist[x][j][pos]=dist[first][j][l]+cost; pq.push({dist[x][j][pos],x,j,pos}); } } else if(!inv) { if(dist[x][j][l]>dist[first][j][l]+cost) { dist[x][j][l]=dist[first][j][l]+cost; pq.push({dist[x][j][l],x,j,l}); } } } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>m; for(int i=1;i<=m;++i) { int x,y,c,d; cin>>x>>y>>c>>d; G[x].pb({y,c,0,i}); G[y].pb({x,c+d,1,i}); } dijkstra(1,dist_from_one); dijkstra(n,dist_from_n); int mini=INF; for(int i=0;i<=m;++i) { int aux1=INF; int aux=INF; for(int j=0;j<=m;++j) { if(i==j) continue; aux=min(aux,dist_from_one[n][i][j]+dist_from_n[1][j][0]); aux1=min(aux1,dist_from_n[1][i][j]+dist_from_one[n][j][0]); } mini=min({mini,aux,aux1}); } if(mini==INF) cout<<-1; else cout<<mini; return 0; }

Compilation message (stderr)

ho_t4.cpp:9: warning: "LLONG_MAX" redefined
    9 | #define LLONG_MAX 9223372036854775807
      | 
In file included from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:195,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:34,
                 from /usr/include/c++/10/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:39,
                 from ho_t4.cpp:1:
/usr/include/limits.h:135: note: this is the location of the previous definition
  135 | #  define LLONG_MAX __LONG_LONG_MAX__
      | 
ho_t4.cpp: In function 'void dijkstra(long long int, std::vector<std::vector<std::vector<long long int> > >&)':
ho_t4.cpp:43:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   43 |         auto [dis,first,j,l]=pq.top();
      |              ^
ho_t4.cpp:45:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   45 |         for(auto [x,cost,inv,pos]:G[node])
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...