이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "train.h"
#include <iostream>
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> > g(n);
for(int i = 0; i < m; ++i) {
g[u[i]].push_back(v[i]);
}
vector<int> dp(n, n);
for(int i = 0; i < 2 * n; ++i) {
vector<int> ndp(n);
for(int j = 0; j < n; ++j) {
if(a[j] == 1) {
ndp[j] = 0;
for(int k : g[j]) {
ndp[j] = max(ndp[j], dp[k] - 1);
}
}
else {
ndp[j] = n;
for(int k : g[j]) {
ndp[j] = min(ndp[j], dp[k] - 1);
}
if(ndp[j] < 0) ndp[j] = 0;
}
if(r[j] == 1 && ndp[j] > 0) {
ndp[j] = n;
}
}
dp = ndp;
}
vector<int> ans(n);
for(int i = 0; i < n; ++i) {
ans[i] = (dp[i] > 0 ? 1 : 0);
}
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... |