제출 #123217

#제출 시각아이디문제언어결과실행 시간메모리
123217cveleWand (COCI19_wand)C++14
70 / 70
124 ms4852 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); if (adj[1].empty()) ok[1] = 1; for (int i = 1; i <= n; i++) { cout << ok[i]; } cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...