# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100526 | 2019-03-12T04:02:41 Z | Feeder | Wand (COCI19_wand) | C++11 | 0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; bool vis[100001]; vector<int> adj[100001]; void dfs(int x){ vis[x] = 1; for(int i=0; i<adj[x].size(); i++){ if(vis[adj[x][i]]) continue; dfs(adj[x][i]); } } int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, m, a, b; cin >> n >> m; for(int i=0; i<m; i++){ cin >> a >> b; adj[b].push_back(a); } for(int i=0; i<adj[1].size(); i++) dfs(adj[1][i]); if(adj[1][i].size() == 0) vis[1] = 1; for(int i=1; i<=n; i++) cout << vis[i]; }