제출 #376633

#제출 시각아이디문제언어결과실행 시간메모리
376633jeroenodbRobot (JOI21_ho_t4)C++14
0 / 100
110 ms11756 KiB
#include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int mxN = 1e5+1; const ll oo = 1e18; map<int,vector<pi>> adj[mxN]; int main() { int n,m; cin >> n >> m; for(int i=0;i<m;++i) { int a,b,c,d; cin >> a >> b >> c >> d; a--,b--; adj[a][c].emplace_back(d,b); } vector<ll> dist(n,oo); dist[0] = 0; struct state { ll d; int at; bool operator<(const state& s) const { return d > s.d; } }; priority_queue<state> pq; pq.push({0,0}); while(!pq.empty()) { auto c = pq.top(); pq.pop(); if(c.d > dist[c.at]) continue; for(auto& [color,v]: adj[c.at]) { sort(all(v)); int k = v.size(); ll total = 0; for(int i=0;i<k-1;++i) { auto [cost,to] = v[i]; total+=cost; ll tmp = cost+c.d; if(tmp<dist[to]) { pq.push({tmp,to}); dist[to] = tmp; } } auto [cost,to] = v.back(); cost = min((ll)cost,total); ll tmp = cost+c.d; if(tmp<dist[to]) { pq.push({tmp,to}); dist[to] = tmp; } } } if(dist[n-1]==oo) { cout << "-1\n"; } else cout << dist[n-1] << '\n'; }

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

Main.cpp: In function 'int main()':
Main.cpp:37:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |         for(auto& [color,v]: adj[c.at]) {
      |                   ^
Main.cpp:42:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   42 |                 auto [cost,to] = v[i];
      |                      ^
Main.cpp:50:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   50 |             auto [cost,to] = v.back();
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...