Submission #607420

# Submission time Handle Problem Language Result Execution time Memory
607420 2022-07-26T17:02:15 Z JeanBombeur Toy Train (IOI17_train) C++17
39 / 100
166 ms 1180 KB
#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 Charge[MAX_NOEUDS];
 
bool Calc[MAX_NOEUDS];
bool Pris[MAX_NOEUDS];

vector <int> CurNodes;

int DegI[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 : CurNodes)
    {
        Calc[i] = false;
        Pris[i] = false;
        Deg[i] = DegI[i];
    }
    return;
}
 
void Add(int noeud) {
    if (Calc[noeud])
        return;
    Calc[noeud] = true;
    for (int dest : Remonte[noeud])
    {
        if (!Pris[dest] && (Arezou[dest] || -- Deg[dest] == 0))
        {
            File[fin ++] = dest;
            Pris[dest] = true;
        }
    }
    return;
}
 
bool Bfs() {
    for (int i : CurNodes)
    {
        if (DP[i] && Charge[i])
            Add(i);
    }
    while (deb < fin)
    {
        Add(File[deb ++]);
    }
    bool isOver = true;
    vector <int> nv;
    for (int i : CurNodes)
    {
        if (DP[i] && !Pris[i])
        {
            DP[i] = false;
            isOver = false;
        }
        else
            nv.push_back(i);
    }
    CurNodes = nv;
    return isOver;
}
 
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];
        Charge[i] = Energie[i];
        DP[i] = true;
        CurNodes.push_back(i);
    }
    for (int i = 0; i < nbAretes; i ++)
    {
        Remonte[Right[i]].push_back(Left[i]);
        DegI[Left[i]] ++;
    }
    Reset();
    while (!Bfs())
        Reset();
        
    vector <int> Ans;
    for (int i = 0; i < nbNoeuds; i ++)
    {
        Ans.push_back(DP[i]);
    }
	return Ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 852 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 5 ms 852 KB Output is correct
4 Correct 6 ms 852 KB Output is correct
5 Correct 7 ms 852 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 4 ms 852 KB Output is correct
8 Correct 7 ms 852 KB Output is correct
9 Correct 4 ms 852 KB Output is correct
10 Correct 4 ms 852 KB Output is correct
11 Correct 3 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 0 ms 340 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 1136 KB Output is correct
2 Correct 94 ms 1180 KB Output is correct
3 Correct 112 ms 1108 KB Output is correct
4 Correct 7 ms 1176 KB Output is correct
5 Correct 9 ms 1108 KB Output is correct
6 Correct 8 ms 1152 KB Output is correct
7 Correct 7 ms 1136 KB Output is correct
8 Correct 7 ms 1108 KB Output is correct
9 Correct 5 ms 1108 KB Output is correct
10 Correct 6 ms 1108 KB Output is correct
11 Correct 6 ms 1108 KB Output is correct
12 Correct 8 ms 980 KB Output is correct
13 Correct 6 ms 1108 KB Output is correct
14 Correct 6 ms 1108 KB Output is correct
15 Correct 7 ms 1108 KB Output is correct
16 Correct 6 ms 1108 KB Output is correct
17 Correct 7 ms 1108 KB Output is correct
18 Correct 166 ms 952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 968 KB Output is correct
2 Correct 10 ms 980 KB Output is correct
3 Correct 11 ms 1128 KB Output is correct
4 Correct 7 ms 1132 KB Output is correct
5 Correct 7 ms 1108 KB Output is correct
6 Correct 7 ms 1124 KB Output is correct
7 Correct 8 ms 1124 KB Output is correct
8 Correct 7 ms 1036 KB Output is correct
9 Correct 8 ms 1108 KB Output is correct
10 Correct 7 ms 1140 KB Output is correct
11 Correct 11 ms 1108 KB Output is correct
12 Correct 7 ms 1108 KB Output is correct
13 Correct 7 ms 1108 KB Output is correct
14 Correct 6 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1108 KB Output is correct
2 Correct 7 ms 1108 KB Output is correct
3 Correct 7 ms 1108 KB Output is correct
4 Correct 6 ms 1108 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 3 ms 852 KB Output is correct
7 Correct 4 ms 852 KB Output is correct
8 Correct 4 ms 852 KB Output is correct
9 Correct 6 ms 828 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 4 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 852 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 5 ms 852 KB Output is correct
4 Correct 6 ms 852 KB Output is correct
5 Correct 7 ms 852 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 4 ms 852 KB Output is correct
8 Correct 7 ms 852 KB Output is correct
9 Correct 4 ms 852 KB Output is correct
10 Correct 4 ms 852 KB Output is correct
11 Correct 3 ms 852 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Incorrect 0 ms 340 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
16 Halted 0 ms 0 KB -