Submission #123216

#TimeUsernameProblemLanguageResultExecution timeMemory
123216cveleWand (COCI19_wand)C++14
63 / 70
123 ms6008 KiB
#include <iostream> #include <sstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cctype> #include <cstring> #include <climits> #include <iomanip> #include <bitset> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <list> #include <map> using namespace std; const int N = 100005; int n, m; bool used[N]; bool ok[N]; vector <int> adj[N]; void dfs(int u, int cnt) { if (cnt > 0) ok[u] = 1; used[u] = 1; for (int v : adj[u]) { if (!used[v] || v == 1) { dfs(v, min(2, cnt + 1)); } } } int main() { cin >> n >> m; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; adj[y].push_back(x); } dfs(1, 0); for (int i = 1; i <= n; i++) { cout << ok[i]; } cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...