# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
617648 | Sergio_2357 | Toy Train (IOI17_train) | C++17 | 9 ms | 1108 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 "train.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vi;
vector<signed> who_wins(vector<signed> a, vector<signed> r, vector<signed> u, vector<signed> v)
{
vector<signed> res(a.size(), 0);
vi ws, ls;
set<int> brk;
for (int i = 0; i < a.size(); i++)
brk.insert(i);
for (int i = 0; i < u.size(); i++) {
if (u[i] == v[i]) {
if (r[u[i]] && a[u[i]])
ws.push_back(u[i]);
if (!r[u[i]] && !a[u[i]])
ls.push_back(u[i]);
} else {
brk.erase(u[i]);
}
}
sort(ws.begin(), ws.end());
sort(ls.begin(), ls.end());
for (int i = 0; i < a.size(); i++) {
auto wit = lower_bound(ws.begin(), ws.end(), i);
auto lit = lower_bound(ls.begin(), ls.end(), i);
auto l2it = brk.lower_bound(i);
int nw = (wit != ws.end() ? *wit : INT_MAX);
int nl = (lit != ls.end() ? *lit : INT_MAX);
int nl2 = (l2it != brk.end() ? *l2it : INT_MAX);
if (nw < nl && nw <= nl2)
res[i] = 1;
}
return res;
}
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... |