Submission #411534

#TimeUsernameProblemLanguageResultExecution timeMemory
411534ak2006Valley (BOI19_valley)C++14
0 / 100
8 ms6988 KiB
#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 (stderr)

valley.cpp: In function 'void setIO()':
valley.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  freopen("input.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
valley.cpp:17:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  freopen("output.txt","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...