# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
418387 | rGamer | 장난감 기차 (IOI17_train) | C++17 | 1975 ms | 262148 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
int dp(vector<int> &a, vector<int> &r, vector<vector<int>> gp, int poz) {
if(ans[poz] != -1)
return ans[poz];
int cur;
if(a[poz]) {
cur = (gp[poz].size() > 1 and r[poz]) ? 1 : dp(a, r, gp, poz + 1);
}
else
cur = (gp[poz].size() > 1 and !r[poz]) ? 0 : dp(a, r, gp, poz + 1);
return ans[poz] = cur;
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size(), m = u.size();
ans = vector<int>(n, -1);
vector<vector<int>> gp(n);
for(int i = 0; i < m; ++i)
gp[u[i]].push_back(v[i]);
ans[n - 1] = r[n - 1];
int kz = 0;
while(kz < n) {
if(ans[kz] == -1)
dp(a, r, gp, kz);
kz++;
}
return ans;
}
Compilation message (stderr)
# | 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... |