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>
#define all(x) x.begin(), x.end()
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define pb push_back
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define x first
#define y second;
using namespace std;
const int N = 1e6;
bool aAlice[N];
vector<int> versMoi[N], voisins[N];
int fuckes[N];
int nNoeuds;
bool aAcces[N];
bool estRecharge[N];
void updRecharges(){
queue<int> file;
for (int noeud = 0; noeud < nNoeuds; ++noeud){
aAcces[noeud] = false;
if (estRecharge[noeud])
file.push(noeud);
fuckes[noeud] = sz(voisins[noeud]);
}
while (!file.empty()){
int noeud = file.front();
file.pop();
for (int avant : versMoi[noeud]){
fuckes[avant] -= (estRecharge[noeud]^aAcces[noeud]);
if ((aAlice[avant] || fuckes[avant] == 0) && !aAcces[avant]){
file.push(avant);
aAcces[avant] = true;
}
}
}
for (int noeud = 0; noeud < nNoeuds; ++noeud)
estRecharge[noeud] &= aAcces[noeud];
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
nNoeuds = sz(a);
for (int noeud = 0; noeud < nNoeuds; ++noeud){
aAlice[noeud] = a[noeud];
estRecharge[noeud] = r[noeud];
}
int nAretes = sz(u);
for (int i = 0; i < nAretes; ++i){
voisins[u[i]].pb(v[i]);
versMoi[v[i]].pb(u[i]);
}
for (int i = 0; i < nNoeuds; ++i)
updRecharges();
vector<int> res(nNoeuds);
for (int i = 0; i < nNoeuds; ++i){
res[i] = aAcces[i];
}
return res;
}
# | 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... |