1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #include<iostream> #include<cstdio> #include<queue> #define fi first #define se second using namespace std; using PII=pair<int,int>; const int N=2e5+10,M=2e5+10; template<class T> inline void read(T &x) { x=0;bool f=0; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=1;ch=getchar();} while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); if(f)x=~x+1; } template<class T,class ...T1> inline void read(T &x,T1 &...x1) { read(x),read(x1...); } int n,m,q; int u[M],v[M],a[M]; bool ans[N]; int tot,head[N],ver[M],ne[M]; int pre[N]; priority_queue<PII>Q; inline void add(int u,int v) { ver[++tot]=v; ne[tot]=head[u]; head[u]=tot; } void Dijkstra() { ver[++tot]=1; Q.push({1,tot}); while(!Q.empty()) { int x=Q.top().second,y=ver[x]; Q.pop(); if(pre[y])continue; pre[y]=x; for(int i=head[y];i;i=ne[i])Q.push({a[i],i}); } } int main() { read(n,m,q); for(int i=1;i<=m;i++)read(u[i],v[i]),add(u[i],v[i]),a[i]=q+1; for(int i=1,x;i<=q;i++) { read(x); if(a[x]>i)ans[a[x]=i]=1; else ans[i]=0; } Dijkstra(); for(int i=n;i!=1;i=u[pre[i]])ans[a[pre[i]]]=0; for(int i=1;i<=q;i++)printf("%d\n",ans[i]); return 0; }
|