Submission #592783

# Submission time Handle Problem Language Result Execution time Memory
592783 2022-07-09T15:34:30 Z Richem Toy Train (IOI17_train) C++14
0 / 100
2000 ms 66088 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] != -1)
        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;
        }
    }

    for(int sommet = 0; sommet < nbSommet; sommet++)
        dfs(sommet);

    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 Runtime error 35 ms 41428 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2093 ms 52848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2083 ms 64100 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2093 ms 66088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 41428 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -