# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
987187 | AdamGS | Toy Train (IOI17_train) | C++17 | 1065 ms | 1880 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;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e3+7;
vector<int>V[LIM], S[LIM];
int deg[LIM];
vector<int>who_wins(vector<int>a, vector<int>r, vector<int>u, vector<int>v) {
int n=a.size(), m=u.size();
vector<int>ans(n);
rep(i, m) {
V[u[i]].pb(v[i]);
S[v[i]].pb(u[i]);
}
rep(i, n) {
rep(j, n) {
ans[j]=0;
if(r[j]) deg[j]=0;
else if(!a[j]) deg[j]=V[j].size();
else deg[j]=1;
}
queue<int>q;
rep(j, n) if(deg[j]==0) q.push(j);
while(!q.empty()) {
int p=q.front(); q.pop();
ans[p]=1;
for(auto j : S[p]) {
--deg[j];
if(deg[j]==0) q.push(j);
}
}
rep(j, n) if(r[j]) {
int sum=0;
for(auto l : V[j]) sum+=ans[l];
if(a[j] && sum==0 || !a[j] && sum<V[j].size()) r[j]=0;
}
}
return ans;
}
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... |