이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "train.h"
#include <iostream>
using namespace std;
const int MAX_NOEUD = 5e3;
const int MAX_ARC = 2e4;
int nbNoeud, nbArc;
bool estProprietaire[MAX_NOEUD];
bool estRechargeable[MAX_NOEUD];
vector<int> result;
vector<int> graphe[MAX_NOEUD];
bool estPossible(int noeudDepart)
{
int curNoeud = noeudDepart;
bool nxtPossible = true;
bool curPossible = false;
while(nxtPossible)
{
nxtPossible = false;
for(int voisin : graphe[curNoeud])
{
if(voisin == curNoeud + 1)
{
nxtPossible = true;
}
if(voisin == curNoeud)
{
curPossible = true;
}
}
if(curPossible && !estProprietaire[curNoeud] && !estRechargeable[curNoeud])
{
return false;
}
if(curPossible && estProprietaire[curNoeud] && estRechargeable[curNoeud])
{
return true;
}
if(!nxtPossible && curPossible)
{
return estRechargeable[curNoeud];
}
curNoeud++;
}
return false;
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v)
{
nbNoeud = (int)a.size();
nbArc = (int)u.size();
for(int iNoeud = 0; iNoeud < nbNoeud; iNoeud++)
{
if(a[iNoeud] == 1)
{
estProprietaire[iNoeud] = true;
}
if(r[iNoeud])
{
estRechargeable[iNoeud] = true;
}
}
for(int iArc = 0; iArc < nbArc; iArc++)
{
graphe[u[iArc]].push_back(v[iArc]);
}
for(int iDep = 0; iDep < nbNoeud; iDep++)
{
if(estPossible(iDep))
{
result.push_back(1);
}
else
{
result.push_back(0);
}
}
return result;
}
# | 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... |