# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
128343 | Harry464 | Wand (COCI19_wand) | C++14 | 134 ms | 5956 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>
#include <queue>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector <int> red;
vector <vector <int> > adjl(n,red);
for (int i = 0; i < m; i++){
int u, v;
cin >> v >> u;
adjl[u-1].push_back(v-1);
}
queue <int> bfs;
bfs.push(0);
bool mog = false;
vector <bool> vis(n);
while (!bfs.empty()){
int s = bfs.front();
bfs.pop();
if (vis[s]) continue;
vis[s] = true;
for(int i = 0; i < adjl[s].size(); i++){
int t = adjl[s][i];
if (t == 0) mog = true;
if (!vis[t]) bfs.push(t);
}
}
if (mog) cout <<"1";
else cout << "0";
for (int i = 1; i < n; i++){
if (vis[i]) cout << "1";
else cout << "0";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |