#include "train.h"
#include <deque>
#include <vector>
using namespace std;
int nbSommets;
vector<int> nouvDegs;
vector<bool> nouvGagnants;
vector<int> estMax;
vector<int> parents[6000];
void explore(int sommet) {
if(nouvGagnants[sommet]) return;
nouvGagnants[sommet] = true;
for(int parent : parents[sommet]) {
if(estMax[parent]) {
explore(parent);
}
else {
nouvDegs[parent]--;
if(nouvDegs[parent] == 0)
explore(parent);
}
}
}
vector<int> who_wins(vector<int> _estMax, vector<int> estRecharge,
vector<int> debs, vector<int> fins) {
estMax = _estMax;
nbSommets = estMax.size();
vector<int> degs(nbSommets);
for(int iArc = 0;iArc < (int)debs.size();iArc++) {
parents[fins[iArc]].push_back(debs[iArc]);
degs[debs[iArc]]++;
}
int nbRecharges = 0;
for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
if(estRecharge[iSommet])
nbRecharges += 1;
}
vector<bool> gagnants(nbSommets, true);
for(int iFois = 0;iFois <= nbRecharges + 1;iFois++) {
nouvDegs = degs;
nouvGagnants = vector<bool>(nbSommets, false);
for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
if(gagnants[iSommet] && estRecharge[iSommet]) {
explore(iSommet);
}
}
gagnants = nouvGagnants;
}
vector<int> estGagnant;
for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
estGagnant.push_back(gagnants[iSommet]);
}
return estGagnant;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
265 ms |
800 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
1240 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
922 ms |
940 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1144 KB |
Output is correct |
2 |
Correct |
9 ms |
1108 KB |
Output is correct |
3 |
Correct |
8 ms |
1108 KB |
Output is correct |
4 |
Correct |
7 ms |
1108 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Incorrect |
4 ms |
768 KB |
3rd lines differ - on the 3730th token, expected: '0', found: '1' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
265 ms |
800 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |