/* Pokemon Go Go Bruce Elenbogen */ #include #include #include #include using namespace std; int abs(int n){ if (n>=0) return n; return -n; } struct Stop{ int row; int col; string name; }; int computeTotalDist(const vector & location, const vector & order){ int totalDist = 0; int size = order.size(); for (int i = 0; i < size-1; i++) totalDist += abs(location[order[i+1]].row - location[order[i]].row)+ abs(location[order[i+1]].col - location[order[i]].col); totalDist += abs(location[order[0]].row - location[order[size-1]].row)+ abs(location[order[0]].col - location[order[size-1]].col); return totalDist; } int findIndex(int index, const vector & uniqueNames){ for (int i = 0; i < uniqueNames.size(); i++) if (index == uniqueNames[i]) return i; return -1; } bool nextPermute(vector & lastPermute, vector > &uniqueNames ){ bool done = false; int index; for(int i = 1 ; i < lastPermute.size()&& !done;i++){ index = findIndex(lastPermute[i], uniqueNames[i]); if (index < 0) system("pause"); if (index & locations, vector > & indexUniqueNames ){ vector temp(1,0); bool placed; string name; indexUniqueNames.push_back(temp); for (int i = 1; i < locations.size(); i++){ name = locations[i].name; placed= false; for (int j = 0; j < indexUniqueNames.size()&& !placed; j++) if (name == locations[indexUniqueNames[j][0]].name){ placed = true; indexUniqueNames[j].push_back(i); } if (!placed){ temp[0]=i; indexUniqueNames.push_back(temp); } } } int main(){ int numStops; vector locations; vector permute; vector temp; vector bestOrder; vector > uniqueNames; int bestDist; int dist; cin>> numStops; locations.resize(numStops+1); //permute.resize(numStops+1); //bestOrder.resize(numStops+1); locations[0].row = 0; locations[0].col = 0; locations[0].name=""; for (int i = 1; i < numStops+1; i++) cin>> locations[i].row>>locations[i].col>>locations[i].name; setUpUniqueNames(locations,uniqueNames ); //cout<<"after set "<