이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |