# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
227242 |
2020-04-26T15:28:31 Z |
DavidDamian |
Wand (COCI19_wand) |
C++11 |
|
44 ms |
5112 KB |
#include <bits/stdc++.h>
using namespace std;
///BFS
///Determine whether the wand can end up in hands of the wizard i
int n,m;
vector<int> adjList[100005];
int color[100005];
queue<int> Q;
void bfs(int s)
{
Q.push(s);
while(Q.size()){
int u=Q.front();
Q.pop();
for(int v: adjList[u]){
if(color[v]==0){
color[v]=1;
Q.push(v);
}
}
}
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m;
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
adjList[b].push_back(a);
}
bfs(1);
if(adjList[1].size()==0) color[1]=1;
for(int i=1;i<=n;i++){
cout<<color[i];
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
38 ms |
4856 KB |
Output is correct |
4 |
Correct |
37 ms |
4856 KB |
Output is correct |
5 |
Correct |
42 ms |
4984 KB |
Output is correct |
6 |
Correct |
40 ms |
4984 KB |
Output is correct |
7 |
Correct |
41 ms |
4992 KB |
Output is correct |
8 |
Correct |
40 ms |
4984 KB |
Output is correct |
9 |
Correct |
42 ms |
4728 KB |
Output is correct |
10 |
Correct |
44 ms |
5112 KB |
Output is correct |