# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
128345 | 2019-07-10T18:52:34 Z | Harry464 | Wand (COCI19_wand) | C++14 | 140 ms | 5880 KB |
#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 (adjl[0].size()==0) mog = true; if (mog) cout <<"1"; else cout << "0"; for (int i = 1; i < n; i++){ if (vis[i]) cout << "1"; else cout << "0"; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 118 ms | 5556 KB | Output is correct |
4 | Correct | 118 ms | 5496 KB | Output is correct |
5 | Correct | 124 ms | 5600 KB | Output is correct |
6 | Correct | 140 ms | 5700 KB | Output is correct |
7 | Correct | 127 ms | 5340 KB | Output is correct |
8 | Correct | 121 ms | 5520 KB | Output is correct |
9 | Correct | 133 ms | 5860 KB | Output is correct |
10 | Correct | 126 ms | 5880 KB | Output is correct |