commit fbe95e78447eab3458619d57f0feb1c726c2f8a9
parent db49cba5e5e5ccd333b8d6668ac4752f8bcc8ca9
Author: Jachiet Louis <louis@jachiet.com>
Date: Sat, 5 Apr 2014 14:06:30 +0200
go_to -> use
Diffstat:
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/contest/louis/algo.cpp b/contest/louis/algo.cpp
@@ -3,6 +3,7 @@
int main()
{
lecture_entree();
+ init_use();
vector<int> chem[8];
for( int i = 0 ; i < 8 ; i++)
{
@@ -13,10 +14,10 @@ int main()
{
while(chem[i].back() == arrivee)
arrivee = rand()%n_sommets ;
- int nouv = go_to(chem[i].back(),arrivee);
+ int nouv = use[chem[i].back()][arrivee];
l+= cout[id_arete[make_pair(chem[i].back(),nouv)]] ;
if(l<t_autorise)
- chem[i].push_back(go_to(chem[i].back(),arrivee));
+ chem[i].push_back(use[chem[i].back()][arrivee]);
// fprintf(stderr,"%d %d %d\n",i,chem[i].back(),arrivee);
}
}
diff --git a/contest/louis/louis.cpp b/contest/louis/louis.cpp
@@ -10,17 +10,19 @@ using namespace std;
const int INF = 1000 * 1000 * 100 ;
short use[N_SOMMETS_MAJ][N_SOMMETS_MAJ] ;
int cur_dist[N_SOMMETS_MAJ] ;
-int init ;
-
+void init_use()
+{
+ FILE * f = fopen("dist","rb");
+ fread(use,sizeof(use),1,f);
+ fclose(f);
+}
// Renvoie la première intersection à utiliser
+/*
int go_to( int depart, int arrivee)
{
if(!init)
{
init = 1 ;
- FILE * f = fopen("dist","rb");
- fread(use,sizeof(use),1,f);
- fclose(f);
}
if(use[depart][depart] == -1)
{
@@ -56,5 +58,16 @@ int go_to( int depart, int arrivee)
if(use[depart][arrivee] == -1)
fprintf(stderr,"ERREUR !\n");
return use[depart][arrivee] ;
-
+}
+*/
+vector<int> complete ( vector<int> c)
+{
+ vector<int> r ;
+ for(size_t i = 0 ; i+1 < c.size() ; i++ )
+ {
+ r.push_back(c[i]);
+ while(r.back() != c[i+1])
+ r.push_back(use[r.back()][c[i]]);
+ }
+ return r ;
}