# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
794176 | alvingogo | Toy Train (IOI17_train) | C++14 | 0 ms | 0 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>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;
typedef long long ll;
const ll inf=1e9;
void print(auto& a){
return;
for(auto h:a){
cerr << h << " ";
}
cerr << "\n";
}
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);
vector<vector<int> > e(n);
for(int i=0;i<m;i++){
e[u[i]].push_back(e[i]);
}
for(int i=n-1;i>=0;i--){
int mx=0,mn=1;
for(auto y:e[i]){
if(y==i){
if(r[i]==1){
mx=1;
}
else{
mn=0;
}
}
else{
mx=max(mx,ans[y]);
mn=mn(mn,ans[y]);
}
}
if(a[i]==0){
ans[i]=mn;
}
else{
ans[i]=mx;
}
}
return ans;
}