답안 #97365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97365 2019-02-15T14:13:01 Z mayhoubsaleh Wand (COCI19_wand) C++14
70 / 70
154 ms 5296 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 114 ms 5092 KB Output is correct
4 Correct 104 ms 5112 KB Output is correct
5 Correct 104 ms 5084 KB Output is correct
6 Correct 123 ms 5112 KB Output is correct
7 Correct 96 ms 5172 KB Output is correct
8 Correct 110 ms 5296 KB Output is correct
9 Correct 154 ms 4984 KB Output is correct
10 Correct 151 ms 5212 KB Output is correct