# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
313682 | 2020-10-16T14:59:04 Z | neki | Wand (COCI19_wand) | C++14 | 131 ms | 6508 KB |
#include <bits/stdc++.h> #define loop(i, a, b) for(long long i=a;i<b;i++) #define pool(i, a, b) for(long long i=a-1;i>=b;i--) #define fore(i, a) for(auto&& i:a) #define fi first #define se second #define ps(a) push_back(a) #define pb(a) pop_back(a) #define sc scanf #define vc vector #define pa pair<ll, ll> #define ll long long #define lb lower_bound #define ub upper_bound #define all(a) a.begin(), a.end() #define llmax LLONG_MAX/2 #define llmin -LLONG_MAX/2 using namespace std; #define mn 101000 #define pa pair<ll, ll> #define ld long double ll vis[mn], can[mn]; vc<ll> edg[mn]; void dfs(ll u){ vis[u]=1; fore(v, edg[u]){ can[v]=1; if(!vis[v]) dfs(v); } } int main(){ ll n, m;cin >> n>> m; loop(i, 0, m){ ll a, b;cin >> a >>b; edg[b].ps(a); } dfs(1); if(edg[1].size()==0) can[1]=1; loop(i, 1, n+1) cout << can[i];cout << endl; }
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 | 6140 KB | Output is correct |
4 | Correct | 116 ms | 6136 KB | Output is correct |
5 | Correct | 118 ms | 6136 KB | Output is correct |
6 | Correct | 131 ms | 6180 KB | Output is correct |
7 | Correct | 117 ms | 6136 KB | Output is correct |
8 | Correct | 122 ms | 6264 KB | Output is correct |
9 | Correct | 126 ms | 4856 KB | Output is correct |
10 | Correct | 128 ms | 6508 KB | Output is correct |