제출 #1252244

#제출 시각아이디문제언어결과실행 시간메모리
1252244knhatdevValley (BOI19_valley)C++20
36 / 100
3093 ms12096 KiB
#include<bits/stdc++.h> #define int long long #define ii pair<int,int> #define fi first #define se second using namespace std; const int N = 1e5 + 5, oo = 1e18; int n, s, q, e, dd[N], dist[N]; int ans; vector<ii> g[N]; struct EDGE { int u, v, c; } edge[N]; bool vst[N]; void dfs(int u) { if(dd[u]) ans = min(ans, dist[u]); vst[u] = 1; for(auto &[v, c] : g[u]) { if(vst[v]) continue; dist[v] = dist[u] + c; dfs(v); } } main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> s >> q >> e; for(int i = 1; i < n; i++) { int u, v, c; cin >> u >> v >> c; edge[i] = {u, v, c}; g[u].push_back({v, c}); g[v].push_back({u, c}); } for(int i = 1; i <= s; i++) { int u; cin >> u; dd[u] = 1; } while(q--) { int i, r; cin >> i >> r; for(int j = 1; j <= n; j++){ g[j].clear(); vst[j] = 0; dist[j] = oo; } for(int j = 1; j < n; j++) { if(j == i) continue; g[edge[j].u].push_back({edge[j].v, edge[j].c}); g[edge[j].v].push_back({edge[j].u, edge[j].c}); } ans = oo; dist[r] = 0; dfs(r); if(vst[e]) cout << "escaped\n"; else { if(ans == oo) cout << "oo\n"; else cout << ans << '\n'; } } }

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

valley.cpp:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...