# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1045840 | pcc | Toy Train (IOI17_train) | C++17 | 5 ms | 1116 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;
const int mxn = 5050;
vector<int> charge;
int N,M;
queue<int> q;
int owner[mxn];
bitset<mxn> reach[mxn],dist;
vector<int> paths[mxn];
bitset<mxn> ban;
bitset<mxn> cyc;
bitset<mxn> state;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
N = a.size();
for(int i = 0;i<N;i++){
owner[i] = a[i];
if(r[i]){
charge.push_back(i);
ban[i] = true;
}
}
for(int i = 0;i<u.size();i++){
int aa = u[i],bb = v[i];
paths[aa].push_back(bb);
}
vector<int> ans(N,-1);
for(int i = N-1;i>=0;i--){
if(!owner[i]){
ans[i] = 0;
for(auto nxt:paths[i]){
if(nxt != i&&state[nxt]){
ans[i] = 1;
}
else if(nxt == i&&ban[i])ans[i] = 1;
}
}
else{
ans[i] = 1;
for(auto nxt:paths[i]){
if(nxt != i&&!state[nxt]){
ans[i] = 0;
}
else if(nxt == i&&!ban[i])ans[i] = 0;
}
}
state[i] = ans[i];
}
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... |