Submission #1064339

#TimeUsernameProblemLanguageResultExecution timeMemory
1064339MalixValley (BOI19_valley)C++14
23 / 100
263 ms17172 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int,int> pi; typedef vector<pi> pii; typedef tuple<int,int,int> tii; typedef vector<ll> li; typedef vector<li> lii; #define REP(i,a,b) for(int i=a;i<b;i++) #define F first #define S second #define PB push_back #define MP make_pair #define LSOne(s) ((s)&(-s)) ll INF=1e18+10; int inf=2e9+10; ll M=1e9+7; int n,m,q,e; vector<vector<pair<int,ll>>> a; pii rds; vi sp,p,sa,se; int sval=0,eval=0; void dfs(int x){ sa[x]=sval++; for(auto u:a[x]){ if(sa[u.F]!=-1)continue; p[u.F]=x; dfs(u.F); } se[x]=eval++; } bool ances(int x,int y){ if(sa[x]>=sa[y]&&se[x]<=se[y])return 1; return 0; } int main() { cin>>n>>m>>q>>e;e--; a.resize(n);p.resize(n,-1);sa.resize(n,-1);se.resize(n,-1); REP(i,0,n-1){ int x,y;ll z; cin>>x>>y>>z; x--;y--; rds.PB({x,y}); a[x].PB({y,z}); a[y].PB({x,z}); } sp.resize(m); REP(i,0,m)cin>>sp[i]; dfs(e); REP(i,0,n-1)if(sa[rds[i].F]<sa[rds[i].S])swap(rds[i].F,rds[i].S); while(q--){ int x,y;cin>>x>>y; x--;y--; if(ances(y,rds[x].F))cout<<0<<"\n"; else cout<<"escaped\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...