# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411534 | 2021-05-25T13:20:11 Z | ak2006 | Valley (BOI19_valley) | C++14 | 8 ms | 6988 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>; using vi = vector<int>; using vvi = vector<vi>; using vb = vector<bool>; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define pb push_back void setIO() { fast; #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif } int n = 1e5 + 5,s,q,root; vi in(n),out(n); vvvl adj(n); vb shop(n); int t; void dfs(int u,int p) { in[u] = t++; for (auto x:adj[u]){ int v = x[0]; if (v == p)continue; dfs(v,u); } out[u] = t++; } bool is_ancestor(int u,int v) { return in[u] <= in[v] && out[u] >= out[v]; } int main() { setIO(); cin>>n>>s>>q>>root; vvi edges; for (int i = 1;i<n;i++){ int u,v,w; cin>>u>>v>>w; adj[u].pb({v,w}); adj[v].pb({u,w}); edges.pb({u,v}); } dfs(root,-1); for (int i = 1;i<=s;i++){ int x; cin>>x; shop[x] = 1; } while (q--){ int pos,u; cin>>pos>>u; int child = edges[pos - 1][0],par = edges[pos - 1][1]; if (in[child] < in[par])swap(child,par); if (!is_ancestor(child,u))cout<<"escaped"<<'\n'; else cout<<0<<'\n'; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 8 ms | 6988 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 8 ms | 6988 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 8 ms | 6880 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 8 ms | 6988 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |