제출 #233674

#제출 시각아이디문제언어결과실행 시간메모리
233674Charis02Commuter Pass (JOI18_commuter_pass)C++14
16 / 100
328 ms26280 KiB
#include<iostream> #include<stdio.h> #include<vector> #include<cmath> #include<queue> #include<string.h> #include<map> #include<set> #include<algorithm> #define ll long long #define pi pair < ll,ll > #define mp(a,b) make_pair(a,b) #define mid (low+high)/2 #define rep(i,a,b) for(int i = a;i < b;i++) #define N 300004 #define INF 1e18 using namespace std; ll n,m,s,t,u,v; ll d[N][3]; vector < pi > graph[N]; void dijkstra(int root,int id) { rep(i,0,n+1) { d[i][id] = INF; } priority_queue < pi > pq; pq.push(mp(0,root)); d[root][id] = 0; while(!pq.empty()) { pi cur = pq.top(); pq.pop(); cur.first*=-1; if(d[cur.second][id] < cur.first) continue; rep(i,0,graph[cur.second].size()) { ll vv = graph[cur.second][i].first; ll cc = graph[cur.second][i].second; if(d[vv][id] > cur.first+cc) { d[vv][id]=cur.first+cc; pq.push(mp(-d[vv][id],vv)); } } } return; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; cin >> s >> t; cin >> u >> v; rep(i,0,m) { ll a,b,c; cin >> a >> b >> c; graph[a].push_back(mp(b,c)); graph[b].push_back(mp(a,c)); } if(s!=u) return 0; dijkstra(s,0); dijkstra(t,1); dijkstra(v,2); ll ans = d[v][0]; rep(L,1,n+1) { if(d[L][1]+d[L][0]==d[t][0]) ans=min(ans,d[L][2]); // cout << "here " << L << " " << ans << endl; } cout << ans << endl; return 0; }

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

commuter_pass.cpp: In function 'void dijkstra(int, int)':
commuter_pass.cpp:14:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,a,b) for(int i = a;i < b;i++)
commuter_pass.cpp:44:13:
         rep(i,0,graph[cur.second].size())
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:44:9: note: in expansion of macro 'rep'
         rep(i,0,graph[cur.second].size())
         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...