• + 1 comment

    I can't seem to get my code to run under 2 seconds. Got the right output otherwise. This loop is what's costing me most:

    for (q = 0; q < nb_steps; q++) {
        for (i=0; i<n; i++) {      
            new_numb_zombies[i] = 0;
            for (k = 0; k < nb_adj[i]; k++) {
                w = adj[i][k];
                new_numb_zombies[i] += numb_zombies[w]/nb_adj[w];
            }
        }
        aux = numb_zombies;
        numb_zombies = new_numb_zombies;
        new_numb_zombies = aux;
    }
    

    Any idea on how I could speed this up ?