제출 #97365

#제출 시각아이디문제언어결과실행 시간메모리
97365mayhoubsalehWand (COCI19_wand)C++14
70 / 70
154 ms5296 KiB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;
int n,m,a,b;
vector<int>v[100005];
bool ans[100005],vis[100005];

void dfs(int nod){
    vis[nod]=1;
    for(auto i:v[nod]){
        ans[i]=1;
        if(!vis[i])dfs(i);
    }
}
int main(){
    cin>>n>>m;
    ans[1]=1;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        if(b==1)ans[1]=0;
        v[b].pb(a);
    }

    dfs(1);
    for(int i=1;i<=n;i++){
        cout<<ans[i];
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...