이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "train.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
int N, M;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v)
{
N = sz(a);
M = sz(u);
vi hasSelfLoop(N, false);
vi connectsToNext(N, false);
for (int i = 0; i < M; ++i)
if (v[i] == u[i])
hasSelfLoop[u[i]] = true;
else
connectsToNext[u[i]] = true;
vi dp(N, false);
for (int v = N - 1; v >= 0; --v)
{
if (a[v] == 1)
{
// A is turn
if ((hasSelfLoop[v] && r[v]) || (v < N && connectsToNext[v] && dp[v + 1]))
dp[v] = true;
else
dp[v] = false;
}
else
{
// B turn
if ((hasSelfLoop[v] && !r[v]) || (v < N && connectsToNext[v] && !dp[v + 1]))
dp[v] = false;
else
dp[v] = true;
}
}
return dp;
}
# | 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... |