#include <iostream>
#include <cstdio>
#include <vector>
#include "train.h"
using namespace std;
const int MAX_NOEUDS = (5000);
vector <int> Remonte[MAX_NOEUDS];
bool DP[MAX_NOEUDS];
bool Arezou[MAX_NOEUDS];
bool Pris[MAX_NOEUDS];
int Deg[MAX_NOEUDS];
int File[MAX_NOEUDS];
int deb = 0, fin = 0;
int nbNoeuds, nbAretes;
void Reset() {
deb = 0, fin = 0;
for (int i = 0; i < nbNoeuds; i ++)
{
Pris[i] = false;
Deg[i] = 0;
}
for (int i = 0; i < nbNoeuds; i ++)
{
for (int dest : Remonte[i])
Deg[dest] ++;
}
return;
}
void Add(int noeud) {
for (int dest : Remonte[noeud])
{
if (!Pris[dest] && Arezou[dest])
{
File[fin ++] = dest;
Pris[dest] = true;
}
if (!Pris[dest] && !Arezou[dest] && -- Deg[dest] == 0)
{
File[fin ++] = dest;
Pris[dest] = true;
}
}
return;
}
void Bfs() {
Reset();
for (int i = 0; i < nbNoeuds; i ++)
{
if (DP[i])
Add(i);
DP[i] = false;
}
while (deb < fin)
{
Add(File[deb ++]);
}
for (int i = 0; i < nbNoeuds; i ++)
{
if (Pris[i])
DP[i] = true;
}
return;
}
vector<int> who_wins(vector<int> Proprio, vector<int> Energie, vector<int> Left, vector<int> Right) {
nbNoeuds = Proprio.size();
nbAretes = Left.size();
for (int i = 0; i < nbNoeuds; i ++)
{
Arezou[i] = Proprio[i];
if (Energie[i])
DP[i] = true;
}
for (int i = 0; i < nbAretes; i ++)
{
Remonte[Right[i]].push_back(Left[i]);
}
for (int i = 0; i < nbNoeuds; i ++)
{
Bfs();
}
vector <int> Ans;
for (int i = 0; i < nbNoeuds; i ++)
{
Ans.push_back(DP[i]);
}
return Ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1069 ms |
872 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1420 ms |
1276 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1884 ms |
1076 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2005 ms |
1228 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1069 ms |
872 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |