제출 #797946

#제출 시각아이디문제언어결과실행 시간메모리
797946LittleCube장난감 기차 (IOI17_train)C++17
0 / 100
419 ms1624 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { int n = a.size(), m = u.size(); vector<vector<int>> E(n), R(n); for (int i = 0; i < m; i++) E[u[i]].emplace_back(v[i]), R[v[i]].emplace_back(u[i]); vector<int> loop(n, 0); for (int i = 0; i < n; i++) { vector<int> req(n, 0); for (int j = 0; j < n; j++) if (r[j]) req[j] = 1e9; else if (a[j]) req[j] = E[j].size(); else req[j] = 1; queue<int> q; q.push(i); while (!q.empty()) { int x = q.front(); q.pop(); for (auto y : R[x]) if (--req[y] == 0) q.emplace(y); } loop[i] = req[i] <= 0; } vector<int> ans(n, 1); vector<int> req(n, 0); queue<int> q; for (int j = 0; j < n; j++) if (loop[j]) { q.push(j); req[j] = 0; } else if (r[j]) req[j] = 1e9; else if (a[j]) req[j] = E[j].size(); else req[j] = 1; while (!q.empty()) { int x = q.front(); ans[x] = 0; q.pop(); for (auto y : R[x]) if (--req[y] == 0) q.emplace(y); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...