# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425820 | Rouge_Hugo | Toy Train (IOI17_train) | C++14 | 1116 ms | 1480 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>
#include "train.h"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;int n,m;
vector<int>ans;
const int N=5090;
int vis[N],yes[N];int o;
vector<int>v[N];
int rr[N];
void d(int x)
{
if(x==o&&vis[x])yes[x]=1;
if(vis[x])return;
vis[x]=1;
for(auto it:v[x])
{
d(it);
}
}
int dfs(int x)
{
if(vis[x])return 0;
if(yes[x])return 1;
vis[x]=1;int z=0;
for(auto it:v[x])
{
z=max(z,dfs(it));
}
return z;
}
vector<int> who_wins(vector<int> A,vector<int> r,vector<int> u,vector<int> uu) {
n=r.size();m=u.size();
for(int i=0;i<n;i++)
rr[i]=r[i];
for(int i=0;i<m;i++)
v[u[i]].pb(uu[i]);
for(int i=0;i<n;i++)
{
if(rr[i]==0)continue;
memset(vis,0,sizeof vis);
o=i;
d(i);
}
for(int i=0;i<n;i++)
{
memset(vis,0,sizeof vis);
ans.pb(dfs(i));
}
return ans;
}
/*
6 7
1 1 1 1 1 1
0 0 0 0 0 1
1 2
2 0
0 1
4 2
3 3
2 5
5 0
*/
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... |