ens-ulm-1-2015

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

commit 5908a09f2caaff16ee2ccaae7aaae4f3a61aa386
parent a2414f77465b341735b9425d3fa9ebaa7850d6e1
Author: Marc Jeanmougin <mc@localhost.localdomain>
Date:   Fri, 27 Mar 2015 21:24:22 +0100

tot

Diffstat:
testing/a3nm/main.cpp | 21+++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/testing/a3nm/main.cpp b/testing/a3nm/main.cpp @@ -19,11 +19,11 @@ vector<int> r2; vector<int> c2; //avant -bool compare_vect(vector<int> x, vector<int> y){ - if(x.size()==y.size()){ - return size[x[0]]<size[y[0]]; +bool compare_vect(int x, int y){ + if(G[x].size()==G[y].size()){ + return size[x]<size[y]; } else { - return x.size()<y.size(); + return G[x].size()<G[y].size(); } } @@ -81,16 +81,21 @@ int main(int argc, char **argv) { } //pendant - sort(G.begin(),G.end(),compare_vect); + vector<int> ids(G.size()); + for (unsigned i = 0; i < G.size(); i++) { + ids[i]=i; + } + + sort(ids.begin(),ids.end(),compare_vect); vector<bool> taken(G.size(),false); vector<int> sortie; vector<bool> choix; for(unsigned int i=0;i<G.size();i++){ - if(taken[G[i][0]])continue; - sortie.push_back(G[i][0]); - for(unsigned int j = 0; j < G[i].size(); j++){ + if(taken[ids[i]])continue; + sortie.push_back(ids[i]); + for(unsigned int j = 0; j < G[ids[i]].size(); j++){ taken[j]=true; } }