Submission #592777

# Submission time Handle Problem Language Result Execution time Memory
592777 2022-07-09T15:23:30 Z Richem Toy Train (IOI17_train) C++14
0 / 100
16 ms 24928 KB
#include <iostream>
#include <vector>

using namespace std;

const int MAX_SOMMET = 5042;

int gagnant[MAX_SOMMET] = {0};

int nbSommet, nbArete;

bool adj[MAX_SOMMET][MAX_SOMMET] = {0};

bool qui[MAX_SOMMET] = {0};
bool recharge[MAX_SOMMET] = {0};

int dfs(int sommet) {
    if(gagnant[sommet] != 0)
        return gagnant[sommet];

    for(int voisin = 0; voisin < MAX_SOMMET; voisin++) {
        if(adj[sommet][voisin] == 0)
            continue;

        dfs(voisin);

        gagnant[sommet] = gagnant[voisin];
    }
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
    nbSommet = a.size();
    nbArete = u.size();

    for(int i = 0; i < nbSommet; i++) {
        gagnant[i] = -1;
        qui[i] = a[i];
        recharge[i] = r[i];
    }

    for(int id = 0; id < nbArete; id++) {
        if(u[id] == v[id]) {
            if(a[u[id]] == 0)
                gagnant[u[id]] = 0;
            if(a[u[id]] == 1 && r[u[id]] == 1)
                gagnant[u[id]] = 1;
        }
        else {
            adj[u[id]][v[id]] = 1;
        }
    }

    dfs(0);

    vector<int> rep;

    for(int i = 0; i < nbSommet; i++)
        rep.push_back(gagnant[i]);

    return rep;
}

Compilation message

train.cpp: In function 'int dfs(int)':
train.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 20704 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 0 ms 308 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 12 ms 20180 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 13 ms 24124 KB 3rd lines differ - on the 1st token, expected: '1', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 24928 KB 3rd lines differ - on the 1st token, expected: '1', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 20704 KB 3rd lines differ - on the 1st token, expected: '0', found: '-1'
2 Halted 0 ms 0 KB -