# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422325 | 2021-06-10T03:10:11 Z | timmyfeng | Toy Train (IOI17_train) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; const int N = 5000; vector<int> to[N], from[N], a; bool win[N], visited[N]; int degree[N], n, m; void bfs() { queue<int> que; for (int i = 0; i < n; ++i) { degree[i] = 0; if (visited[i]) { que.push(i); } } while (!que.empty()) { int u = que.front(); que.pop(); for (auto c : from[u]) { if (!visited[c]) { if (a[c] == 1 || ++degree[c] == (int) to[c].size()) { visited[c] = true; que.push(c); } } } } }