Submission #1093056

#TimeUsernameProblemLanguageResultExecution timeMemory
1093056Dennis_JasonOlympic Bus (JOI20_ho_t4)C++14
0 / 100
165 ms140120 KiB
#include <bits/stdc++.h> #define NMAX 1000001 #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> //#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=================== =====================END======================== */ int n,m; vector<vector<tpl>>G(NMAX); vector<vector<int>>dist_from_one(NMAX,vector<int>(2,INF)); vector<vector<int>>dist_from_n(NMAX,vector<int>(2,INF)); void dijkstra(int node,vector<vector<int>>&dist) { priority_queue<tpl,vector<tpl>,greater<tpl>>pq; dist[node][0]=0; pq.push({dist[node][0],node,0}); bool use[NMAX][2]; memset(use,false,sizeof(use)); while(!pq.empty()) { auto[dis,first,inverted]=pq.top(); pq.pop(); if(use[first][inverted]) continue; use[first][inverted]=1; for(auto [x,cost,inv]:G[first]) { if(inverted && inv) continue; if(!inverted && inv) { if(dist[x][1]>dist[first][inverted]+cost) { dist[x][1]=dist[first][inverted]+cost; pq.push({dist[x][1],x,1}); } } else if(!inv) { if(dist[x][inverted]>dist[first][inverted]+cost) { dist[x][inverted]=dist[first][inverted]+cost; pq.push({dist[x][inverted],x,inverted}); } } } } } 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}); G[y].pb({x,c+d,1}); } dijkstra(1,dist_from_one); dijkstra(n,dist_from_n); int mini=min(dist_from_n[1][0]+dist_from_one[n][1],dist_from_n[1][1]+dist_from_one[n][0]); mini=min(mini,dist_from_n[1][0]+dist_from_one[n][0]); if(mini>=INF) cout<<-1; else cout<<mini; return 0; }

Compilation message (stderr)

ho_t4.cpp:8: warning: "LLONG_MAX" redefined
    8 | #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<long long int> >&)':
ho_t4.cpp:39:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   39 |         auto[dis,first,inverted]=pq.top();
      |             ^
ho_t4.cpp:44:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |         for(auto [x,cost,inv]:G[first])
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...