# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
801934 | Trisanu_Das | Wand (COCI19_wand) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
bool vis[100001];
vector<int> adj[100001];
void dfs(int u){
vis[u] = true;
for(int i = 0; i < adj[u].size(); i++){
if(!vis[adj[u][i]]) dfs(adj[u][i]);
}
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
int n, m,;
cin >> n >> m;
for(int i = 0; i < m; i++){
int u, v; cin >> u >> v;
adj[v].push_back(u);
}
for(int i = 0; i < adj[1].size(); i++) dfs(adj[1][i]);
if(adj[1].size() == 0) vis[1] = 1;
for(int i = 1; i < n + 1; i++) cout << vis[i];
}