제출 #1021918

#제출 시각아이디문제언어결과실행 시간메모리
1021918HishamAlshehriValley (BOI19_valley)C++17
0 / 100
8 ms604 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> using namespace std; //using namespace __gnu_pbds; #define int long long #define mod 1000000007 #define base 7001 #define base2 757 // #define pi acos(-1) #define double long double //#define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> //#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> #pragma GCC optimize("O3,Ofast,unroll-loops") #pragma GCC target("avx2,sse3,sse4,avx") constexpr int maxn = 1000001; const int N = 1 << (int)(ceil(log2(maxn))); int n, s, q, e; array<int,2> edge[1001]; bool vis[1001], shop[1001]; vector<pair<int,int>>adj[1001]; int dfs(int i, int a, int b) { vis[i] = 1; int mn = INT_MAX; for (auto [j, w] : adj[i]) { if ((j == a && i == b) || (j == b && i == a)) continue; if (!vis[j]) mn = min(dfs(j, a, b) + w, mn); } if (shop[i]) return 0; return mn; } signed main() { cin.tie(0) -> sync_with_stdio(0); cin >> n >> s >> q >> e; for (int i = 1; i < n; i++) { int u, v, w; cin >> u >> v >> w; edge[i] = {u, v}; adj[u].push_back({v, w}); adj[v].push_back({u, w}); } for (int i = 0; i < s; i++) { int u; cin >> u; shop[u] = 1; } while (q--) { memset(vis, 0, sizeof vis); int i, r; cin >> i >> r; int mn = dfs(r, edge[i][0], edge[i][1]); if (vis[e]) cout << "escaped\n"; else if (mn != INT_MAX) cout << mn << "\n"; else cout << "oo\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...