Submission #910028

#TimeUsernameProblemLanguageResultExecution timeMemory
910028VMaksimoski008Valley (BOI19_valley)C++14
23 / 100
74 ms15836 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const int LOG = 20; int n, s, q, e, timer = 0; vector<vector<pii> > graph; vector<int> stores, in, out; void dfs(int u, int p) { in[u] = timer++; for(auto &[v, w] : graph[u]) { if(v == p) continue; dfs(v, u); } out[u] = timer; } bool anc(int u, int v) { return (in[u] <= in[v] && out[u] >= out[v]); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> s >> q >> e; graph.resize(n+1); in.resize(n+1); out.resize(n+1); stores.resize(s); vector<pii> edges; for(int i=0; i<n-1; i++) { int a, b, w; cin >> a >> b >> w; edges.push_back({ a, b }); graph[a].push_back({ b, w }); graph[b].push_back({ a, w }); } for(int &x : stores) cin >> x; dfs(1, 0); for(pii &e : edges) if(in[e.first] < in[e.second]) swap(e.first, e.second); while(q--) { int I, R; cin >> I >> R; pii edge = edges[I-1]; if(anc(edge.first, R) == anc(edge.first, e)) { cout << "escaped\n"; continue; } cout << "0\n"; } return 0; }

Compilation message (stderr)

valley.cpp: In function 'void dfs(int, int)':
valley.cpp:15:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |     for(auto &[v, w] : graph[u]) {
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...