# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
227242 | DavidDamian | Wand (COCI19_wand) | C++11 | 44 ms | 5112 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|---|---|---|---|
Fetching results... |