#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y;
short int v[100000];
vector<int> d[100001];
queue<int> q;
void bfs(int x){
if(!d[x].empty())
for (vector<int>::iterator it=d[x].begin();it != d[x].end(); ++it){
if(v[*it]==0){q.push(*it); v[*it]=1;}
}
y = q.front();
q.pop();
bfs(y);
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i=0;i<m;i++){
cin >> x >> y;
d[y].push_back(x);
}
bfs(1);
for (int i=0;i<m;i++) cout << v[i];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
8 ms |
5376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
9 ms |
5120 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
44 ms |
9976 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
58 ms |
10048 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
45 ms |
10332 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
65 ms |
10616 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
53 ms |
10232 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
45 ms |
10360 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
55 ms |
10160 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
58 ms |
10592 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |