# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68398 | Talant | Toy Train (IOI17_train) | C++17 | 2037 ms | 80828 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];
int ed[5005][5005];
bool f[N];
bool was[N];
vector <int> g[N];
vector <int> res;
deque <int> cur;
void dfs (int e,int v) {
was[v] = 1;
cur.pb(v);
for (auto to : g[v]) {
if (!was[to]) {
if (ed[v][to] && ed[to][v]) {
if (v == e) f[v] = 1;
f[to] |= f[v];
}
dfs(e,to);
}
if (f[to] || to == e) {
f[e] = 1;
for (int i = cur.size() - 1; i >= 0; i --) {
if (f[cur[i]]) break;
f[cur[i]] = 1;
}
}
}
cur.pop_back();
}
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]);
ed[u[i]][v[i]] = 1;
}
for (int i = 0; i < a.size(); i ++)
res.pb(0);
for (int i = 0; i < r.size(); i ++) {
if (r[i]) {
cur.clear();
for (int j = 0; j < r.size(); j ++)
f[j] = 0,was[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... |