Submission #921320

#TimeUsernameProblemLanguageResultExecution timeMemory
921320JoksimKaktusWand (COCI19_wand)C++17
70 / 70
23 ms5468 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; void output(bool yes){yes ? cout << "Yes" << "\n" : cout << "No" << "\n";} vector <int> adj[100005]; vector <int> res(100005); vector <int> vis(100005); void find(int i){ vis[i]=true; for(int j : adj[i]){ res[j]=1; if(vis[j])continue; find(j); } vis[i]=false; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); int n,m; cin >> n >> m; for(int i = 0;i < m;i++){ int u,v; cin >> u >> v; u--; v--; adj[v].push_back(u); } find(0); if(adj[0].size() == 0)res[0]=1; for(int i = 0;i < n;i++){ cout << res[i]; } }
#Verdict Execution timeMemoryGrader output
Fetching results...