답안 #227240

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227240 2020-04-26T15:15:32 Z DavidDamian Wand (COCI19_wand) C++11
63 / 70
43 ms 6268 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);
    for(int i=1;i<=n;i++){
        cout<<color[i];
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 39 ms 5880 KB Output is correct
4 Correct 42 ms 6008 KB Output is correct
5 Correct 39 ms 6008 KB Output is correct
6 Correct 43 ms 6136 KB Output is correct
7 Correct 41 ms 5880 KB Output is correct
8 Correct 39 ms 6016 KB Output is correct
9 Incorrect 39 ms 5880 KB Output isn't correct
10 Correct 40 ms 6268 KB Output is correct