제출 #574891

#제출 시각아이디문제언어결과실행 시간메모리
574891ac2huCommuter Pass (JOI18_commuter_pass)C++14
0 / 100
483 ms262144 KiB
#include <bits/stdc++.h> #ifdef DEBUG #include "../templates/debug.h" #else #define deb(x...) #endif using namespace std; #define int long long signed main() { iostream::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int n, m;cin >> n >> m; int s, t;cin >> s >> t; --s;--t; int u, v;cin >> u >> v; --u;--v; vector<array<int, 3>> fake_edg(m); vector<vector<pair<int, int>>> fake_adj(n); for(auto &[a, b, c] : fake_edg){ cin >> a >> b >> c; --a;--b; fake_adj[a].push_back({b, c}); fake_adj[b].push_back({a, c}); } set<pair<int,int>> selected_edges;/*{{{*//*{{{*/ priority_queue<pair<int,int>> pq; vector<int> fake_dist(n, 1e18); fake_dist[s] = 0; pq.push({-fake_dist[s], s}); while(!pq.empty()){ auto [dd, x] = pq.top(); dd = -dd; pq.pop(); if(fake_dist[x] != dd)continue; for(auto [e, w] : fake_adj[x]){ if(fake_dist[e] > fake_dist[x] + w){ fake_dist[e] = fake_dist[x] + w; pq.push({-fake_dist[e], e}); } } } pq.push({-fake_dist[s], s}); vector<vector<pair<int,int>>> temp_adj(n); while(!pq.empty()){ auto [dd, x] = pq.top(); dd = -dd; pq.pop(); for(auto [e, w] : fake_adj[x]){ if(fake_dist[e] == fake_dist[x] + w){ temp_adj[e].push_back({x, w}); pq.push({-fake_dist[e], e}); } } } fill(fake_dist.begin(), fake_dist.end(), 1e18); fake_dist[t] = 0; pq.push({-fake_dist[t], t}); while(!pq.empty()){ auto [dd, x] = pq.top(); dd = -dd; pq.pop(); for(auto [e, w] : temp_adj[x]){ if(fake_dist[e] > fake_dist[x] + w){ fake_dist[e] = fake_dist[x] + w; pq.push({-fake_dist[e], e}); } } } // pq.push({-fake_dist[t], t}); // vector<int> lev(n, -1); // lev[t] = 0; // while(!pq.empty()){ // auto [dd, x] = pq.top(); // dd = -dd; // pq.pop(); // for(auto [e, w] : temp_adj[x]){ // if(fake_dist[e] == fake_dist[x] + w){ // selected_edges.insert({min(e, x), max(e, x)}); // lev[e] = lev[x] + 1; // pq.push({-fake_dist[e], e}); // } // } // }/*}}}*//*}}}*/ // deb(selected_edges);{{{ // deb(lev); // vector<vector<pair<int,int>>> adj(n); // for(auto [a, b, c] : fake_edg){ // if(a > b)swap(a, b); // if(selected_edges.find({a, b}) != selected_edges.end()){ // if(lev[a] < lev[b]){ // deb(a, b); // adj[a].push_back({b, 0}); // adj[b].push_back({a, c}); // } // else{ // deb(b, a); // adj[b].push_back({a, 0}); // adj[a].push_back({b, c}); // } // } // else{ // adj[a].push_back({b, c}); // adj[b].push_back({a, c}); // } // } // vector<int> dist(n, 1e18); // dist[u] = 0; // pq.push({-dist[u], u}); // while(!pq.empty()){ // auto [dd, x] = pq.top(); // pq.pop(); // dd = -dd; // if(dist[x] != dd)continue; // for(auto [e, w] : adj[x]){ // if(dist[e] > dist[x] + w){ // dist[e] = dist[x] + w; // pq.push({-dist[e], e}); // } // } // } // int ans = dist[v]; // cout << ans << "\n"; // adj.clear(); // adj.resize(n); // for(auto [a, b, c] : fake_edg){/*{{{*/ // if(a > b)swap(a, b); // if(selected_edges.find({a, b}) != selected_edges.end()){ // if(lev[a] > lev[b]){ // deb(a, b); // adj[a].push_back({b, 0}); // adj[b].push_back({a, c}); // } // else{ // deb(b, a); // adj[b].push_back({a, 0}); // adj[a].push_back({b, c}); // } // } // else{ // adj[a].push_back({b, c}); // adj[b].push_back({a, c}); // } // } // fill(dist.begin(), dist.end(), 1e18); // dist[u] = 0; // pq.push({-dist[u], u}); // while(!pq.empty()){ // auto [dd, x] = pq.top(); // pq.pop(); // dd = -dd; // if(dist[x] != dd)continue; // for(auto [e, w] : adj[x]){ // if(dist[e] > dist[x] + w){ // dist[e] = dist[x] + w; // pq.push({-dist[e], e}); // } // } // } // ans = min(ans, dist[v]); // cout << ans << "\n";/*}}}*//*}}}*/ }

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

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:17:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   17 |     for(auto &[a, b, c] : fake_edg){
      |               ^
commuter_pass.cpp:29:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |         auto [dd, x] = pq.top();
      |              ^
commuter_pass.cpp:33:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |         for(auto [e, w] : fake_adj[x]){
      |                  ^
commuter_pass.cpp:43:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   43 |         auto [dd, x] = pq.top();
      |              ^
commuter_pass.cpp:46:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   46 |         for(auto [e, w] : fake_adj[x]){
      |                  ^
commuter_pass.cpp:57:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   57 |         auto [dd, x] = pq.top();
      |              ^
commuter_pass.cpp:60:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   60 |         for(auto [e, w] : temp_adj[x]){
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...