제출 #671640

#제출 시각아이디문제언어결과실행 시간메모리
671640smartmonkyEvacuation plan (IZhO18_plan)C++14
41 / 100
4051 ms35232 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define int long long using namespace std; const int N = 1e5 + 10; int d[N]; vector < pair <int,int> > g[N]; int n; int dji(int f, int s){ vector <int> dist(n + 1, -1e9); set <pair <int,int> > st; st.insert({0, f}); dist[f] = d[f]; while (!st.empty()) { int v = (--st.end())->second; st.erase (--st.end()); if(v == s){ return dist[v]; } for (size_t j=0; j< g[v].size(); ++j) { int to = g[v][j].first; if (min(dist[v], d[to]) > dist[to]) { st.erase (make_pair (d[to], to)); dist[to] = min(dist[v], d[to]); st.insert (make_pair (d[to], to)); } } } } main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(d, 0x3f3f, sizeof(d)); int m; cin >> n >> m; for(int i = 0; i < m; i++){ int a, b, c; cin >> a >> b >> c; g[a].pb({b, c}); g[b].pb({a, c}); } int k; cin >> k; set <pair <int,int> > st; for(int i = 0; i < k; i++){ int a; cin >> a; st.insert({0, a}); d[a] = 0; } while (!st.empty()) { int v = st.begin()->second; st.erase (st.begin()); for (size_t j=0; j<g[v].size(); ++j) { int to = g[v][j].first, len = g[v][j].second; if (d[v] + len < d[to]) { d[to] = d[v] + len; st.insert (make_pair (d[to], to)); } } } int q; cin >> q; while(q--){ int a, b; cin >> a >> b; cout << dji(a,b) << endl; } }

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

plan.cpp:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main(){
      | ^~~~
plan.cpp: In function 'long long int dji(long long int, long long int)':
plan.cpp:16:31: warning: control reaches end of non-void function [-Wreturn-type]
   16 |  vector <int> dist(n + 1, -1e9);
      |                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...