ens-ulm-1

google hashcode 2014 source for team ens-ulm-1
git clone https://a3nm.net/git/ens-ulm-1/
Log | Files | Refs

commit eac36eef984258e0892b35aa8b8a5ebabf5a77a7
parent 0a47ec4047cc8af7f4964237dda6ad9b5b7d3b9d
Author: Jachiet Louis <louis@jachiet.com>
Date:   Sat,  5 Apr 2014 13:10:38 +0200

.

Diffstat:
contest/louis/louis.cpp | 53+++++++++++++++++++++++++----------------------------
1 file changed, 25 insertions(+), 28 deletions(-)

diff --git a/contest/louis/louis.cpp b/contest/louis/louis.cpp @@ -7,33 +7,31 @@ using namespace std; -class louis -{ - - const int nbVoitures = 8 ; - const int nbSommets = 11348 ; - const int nbArcs = 17958 ; - const int nbSecondes = 54000 ; - const int depart = 4516 ; - const int INF = 1000 * 1000 * 100 ; - short use[nbSommets][nbSommets] ; - int cur_dist[nbSommets] ; +const int nbVoitures = 8 ; +const int nbSommets = 11348 ; +const int nbArcs = 17958 ; +const int nbSecondes = 54000 ; +const int depart = 4516 ; +const int INF = 1000 * 1000 * 100 ; +short use[nbSommets][nbSommets] ; +int cur_dist[nbSommets] ; +int init ; - louis() - { - fill(use[0],use[nbSommets],-1); - } - - // Renvoie la première intersection à utiliser - int go_to( int depart, int arrivee) - { - if(use[depart][depart] == -1) - return use[depart][arrivee] ; - fill(cur_dist,cur_dist+nbSommets,INF); - priority_queue<pair<int,int> > todo ; - use[depart][depart] = depart ; - todo.push(makepair(0,depart)); - use[depart] +// Renvoie la première intersection à utiliser +int go_to( int depart, int arrivee) +{ + if(!init) + { + init = 1 ; + fill(use[0],use[nbSommets],-1); + } + if(use[depart][depart] == -1) + return use[depart][arrivee] ; + fill(cur_dist,cur_dist+nbSommets,INF); + priority_queue<pair<int,int> > todo ; + use[depart][depart] = depart ; + todo.push(makepair(0,depart)); + use[depart] while(!todo.empty()) { pair<int,int> t = todo.top(); @@ -57,5 +55,4 @@ class louis } } } - } -}; +}