Submission #222095

#TimeUsernameProblemLanguageResultExecution timeMemory
222095VimmerWand (COCI19_wand)C++14
70 / 70
48 ms4728 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define N 100005 #define MOD ll(998244353) using namespace std; typedef long long ll; typedef long double ld; vector <int> g[N]; bool mk[N]; void dfs(int v, int p) { if (p != -1) mk[v] = 1; bool f = 0; for (auto it : g[v]) { if (mk[it]) continue; f = 1; dfs(it, v); } if (!f) mk[v] = 1; } int main() { ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; if (n == 1) mk[1] = 1; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; g[y].pb(x); } dfs(1, -1); for (int i = 1; i <= n; i++) cout << mk[i]; }
#Verdict Execution timeMemoryGrader output
Fetching results...