# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68247 | Talant | Toy Train (IOI17_train) | C++17 | 1282 ms | 25056 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 "grader.cpp"
#include <bits/stdc++.h>
#define mk make_pair
#define sc second
#define fr first
#define pb push_back
using namespace std;
const int N = (1e6 + 5);
const int inf = (1e9 + 7);
int pr[N];
bool f[N];
bool was[N];
vector <int> g[N],res;
void dfs (int e,int v) {
was[v] = 1;
for (auto to : g[v]) {
if (!was[to]) {
pr[to] = v;
dfs(e,to);
}
else if (was[to] && to == e) {
f[to] = 1,f[v] = 1;
}
f[v] |= f[to];
}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
for (int i = 0; i < u.size(); i ++)
g[u[i]].pb(v[i]);
for (int i = 0; i < a.size(); i ++)
res.pb(0);
for (int i = 0; i < r.size(); i ++) {
if (r[i]) {
for (int j = 0; j < r.size(); j ++)
was[j] = 0,f[j] = 0;
dfs(i,i);
for (int j = 0; j < r.size(); j ++) {
res[j] |= f[j];
}
}
}
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... |