# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
313918 | 2020-10-17T09:58:29 Z | phathnv | Wand (COCI19_wand) | C++11 | 128 ms | 4856 KB |
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "WAND" using namespace std; typedef long long ll; typedef pair <int, int> ii; const int N = 100001; int n, m; vector <int> adj[N]; bool vst[N]; void readInput(){ cin >> n >> m; for(int i = 1; i <= m; i++){ int u, v; cin >> u >> v; adj[v].push_back(u); } } void dfs(int u){ for(int v : adj[u]){ if (vst[v]) continue; vst[v] = 1; dfs(v); } } void solve(){ dfs(1); if (adj[1].empty()) vst[1] = 1; for(int i = 1; i <= n; i++) cout << (vst[i]? '1' : '0'); } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 117 ms | 4600 KB | Output is correct |
4 | Correct | 114 ms | 4600 KB | Output is correct |
5 | Correct | 116 ms | 4600 KB | Output is correct |
6 | Correct | 128 ms | 4856 KB | Output is correct |
7 | Correct | 116 ms | 4600 KB | Output is correct |
8 | Correct | 121 ms | 4600 KB | Output is correct |
9 | Correct | 126 ms | 4600 KB | Output is correct |
10 | Correct | 128 ms | 4856 KB | Output is correct |