제출 #948529

#제출 시각아이디문제언어결과실행 시간메모리
948529phone64bitCommuter Pass (JOI18_commuter_pass)C++14
0 / 100
119 ms25156 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxN = 1e5+10; struct Q { int src; ll w; bool operator < (const Q&rhs) const { return w>rhs.w; } }; struct path { int dest; ll w; }; struct edge { int u, v; }; vector<edge> k_path, tmp_path; vector<path> edges[mxN]; bitset<mxN> vs; ll dp[mxN], k_dp[mxN], ans = 1e18; int n,m,s,t,u,v; priority_queue<Q> pq; void dfs(int u) { vs[u]=1; if(u==t&&k_path.size()<tmp_path.size()) { k_path = tmp_path; return; } for(auto v: edges[u]) if(!vs[v.dest]) vs[v.dest]=1, tmp_path.push_back({u, v.dest}), dfs(v.dest), tmp_path.pop_back(); } int main() { for(int i=0; i<mxN; i++) dp[i]=1e18; scanf("%d%d%d%d%d%d", &n,&m,&s,&t,&u,&v); while(m--) { int u, v; ll w; scanf("%d%d%lld", &u, &v, &w); edges[u].push_back({v, w}); edges[v].push_back({u, w}); } dfs(s); for(auto x: k_path) edges[x.u].push_back({x.v, 0}), edges[x.v].push_back({x.u, 0}); dp[u] = 0; pq.push({u, 0}); while(!pq.empty()) { auto [src, w] = pq.top(); pq.pop(); if(src==v) { ans=w; break; } for(auto v: edges[src]) { if(dp[v.dest]>w+v.w) { dp[v.dest]=w+v.w; pq.push({v.dest, dp[v.dest]}); } } } printf("%lld", ans); return 0; }

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

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:51:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   51 |         auto [src, w] = pq.top();
      |              ^
commuter_pass.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     scanf("%d%d%d%d%d%d", &n,&m,&s,&t,&u,&v);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:42:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         int u, v; ll w; scanf("%d%d%lld", &u, &v, &w);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...