# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67513 | zscoder | Toy Train (IOI17_train) | C++17 | 549 ms | 16764 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;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> ii;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
vi adj[22222];
vi radj[22222];
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
std::vector<int> res(a.size(),0);
int n=res.size();
for(int i=0;i<u.size();i++)
{
adj[u[i]].pb(v[i]); radj[v[i]].pb(u[i]);
}
while(1)
{
vector<int> deg(n,0); vector<int> visited(n,0);
for(int i=0;i<n;i++) deg[i]=adj[i].size();
queue<int> q;
for(int i=0;i<n;i++){if(r[i]) q.push(i);}
while(!q.empty())
{
int u=q.front(); q.pop();
for(int v:radj[u])
{
if(a[v])
{
if(!visited[v])
{
visited[v]=1;
if(!r[v]) q.push(v); //or else double count for case 2
}
}
else
{
deg[v]--;
if(!deg[v])
{
if(!visited[v])
{
visited[v]=1;
if(!r[v]) q.push(v);
}
}
}
}
}
bool edit=0;
for(int i=0;i<n;i++){if(r[i]&&!visited[i]) r[i]=0,edit=1;}
if(edit) continue;
res=visited; break;
}
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... |