# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96666 | Ort | Wand (COCI19_wand) | C++11 | 70 ms | 5880 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<vector>
using namespace std;
vector<vector<int> > g;
vector<bool> v;
void dfs(int s) {
for(int u=0;u<g[s].size();u++) {
if(!v[g[s][u]]) {
v[g[s][u]] = 1;
dfs(g[s][u]);
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<int> vi;
g.insert(g.begin(),n+1,vi);
v.insert(v.begin(),n+1,0);
int a, b;
for(int i=0;i<m;i++) {
cin >> b >> a;
a--; b--;
g[a].push_back(b);
}
dfs(0);
bool ok = 0;
for(int i=1;i<n;i++) {
if(v[i]==1) ok = 1;
}
if(ok) {
for(int i=0;i<n;i++) {
cout << v[i];
}
}
else {
cout << 1;
for(int i=1;i<n;i++) {
cout << 0;
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |