제출 #145659

#제출 시각아이디문제언어결과실행 시간메모리
145659XylofoSky Walking (IOI19_walk)C++14
컴파일 에러
0 ms0 KiB
#include "walk.h" #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define eb emplace_back typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const ll INF =1e18; #define debug(...) //ignore template<class T> auto dijkstra(int source, vector<vector<pair<int, T>>> &g) { int n = sz(g); vector<T> dist(n, numeric_limits<T>::max()); vector<pair<int,T> > dad(n, {-1, 0}); priority_queue<pair<T,int> > pq; dist[source] = 0; pq.emplace(0,source); while(!pq.empty()) { T d; int x; tie(d,x) = pq.top(); d = -d; pq.pop(); if(d > dist[x]) continue; for(auto [y,w] : g[x]) { if(dist[y] > d + w) { dist[y] = d + w; dad[y] = {x, w}; pq.emplace(-dist[y], y); } } } return pair{dist, dad}; } ll min_distance(vi x, vi h, vi l, vi r, vi y, int s, int g) { int n = sz(x), m = sz(l); debug(n,m); auto stALL= [&](){ vector<map<ll,int>> Q; auto pcomp = [&] (vi idx) { Q.emplace_back(); int hh = 0; for(int i : idx) if(h[i] > hh) { hh = h[i]; Q.back()[hh] = i; } }; { vi ind; rep(i,s,n) ind.emplace_back(i); pcomp(ind); } { vi ind; for(int i = s; i >= 0; --i) ind.emplace_back(i); pcomp(ind); } { vi ind; rep(i,g,n) ind.emplace_back(i); pcomp(ind); } { vi ind; for(int i = g; i >= 0; --i) ind.emplace_back(i); pcomp(ind); } debug(Q); map<ll, map<ll, int> > V; map<int, pair<ll,ll>> iV; vector<vector<pair<int,ll>>> E; auto at = [&](int i, int h) { if (!V[x[i]].count(h)) { V[x[i]][h] = sz(E); iV[sz(E)] = {x[i],h}; debug(i,h); E.emplace_back(); } return V[x[i]][h]; }; auto edge = [&](int a, int b, ll c) { E[a].emplace_back(b,c); E[b].emplace_back(a,c); }; auto edges = [&](map<ll,int> vert) { pair<ll,int> a = *vert.begin(); vert.erase(vert.begin()); for(auto b : vert) { edge(a.second, b.second, b.first-a.first); a = b; } }; at(s,0); at(g,0); rep(i,0,m) { l[i], r[i], y[i]; map<ll, int> vert; vert[x[l[i]]] = at(l[i], y[i]); vert[x[r[i]]] = at(r[i], y[i]); for(auto &q: Q) { auto it = q.lower_bound(y[i]); if(it == q.end()) continue; int j = it->second; debug("HEJ", i,j); if(l[i] <= j && j <= r[i]) vert[x[j]] = at(j, y[i]); } edges(vert); } for(auto v: V) edges(v.second); debug(sz(E)) auto[dist, dad] = dijkstra(at(s,0),E); for(int q = at(g,0); dad[q].first != -1; q = dad[q].first) { debug(iV[q]); } ll ans = dist[at(g, 0)]; if (ans >= INF) ans = -1; return ans; }; return stALL(); }

컴파일 시 표준 에러 (stderr) 메시지

walk.cpp: In function 'auto dijkstra(int, std::vector<std::vector<std::pair<int, T> > >&)':
walk.cpp:35:14: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
     for(auto [y,w] : g[x]) {
              ^
walk.cpp:43:14: error: missing template arguments before '{' token
   return pair{dist, dad};
              ^
walk.cpp:43:14: error: expected ';' before '{' token
walk.cpp:43:24: error: expected ';' before '}' token
   return pair{dist, dad};
                        ^
walk.cpp: In lambda function:
walk.cpp:116:9: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
     auto[dist, dad] = dijkstra(at(s,0),E);
         ^
walk.cpp: In instantiation of 'auto dijkstra(int, std::vector<std::vector<std::pair<int, T> > >&) [with T = long long int]':
walk.cpp:116:41:   required from here
walk.cpp:43:19: warning: left operand of comma operator has no effect [-Wunused-value]
   return pair{dist, dad};
               ~~~~^~~~~
walk.cpp:43:15: warning: right operand of comma operator has no effect [-Wunused-value]
   return pair{dist, dad};
               ^~~~
walk.cpp:116:9: error: 'void <anonymous>' has incomplete type
     auto[dist, dad] = dijkstra(at(s,0),E);
         ^~~~~~~~~~~