Find the same points on different routes



  • Good evening,

    Please tell me how it is possible and better to check if there is an element on another route to count the amount of people... For example: I have a route 69-87-163-24 and a route 83-163-23-0. The second route contains element 163, so I can also establish a route 69-87-163-83, 69-87-163-23 and 69-87-163-0.

    for (auto i = route.begin(); i != route.end(); i++)
        {
            for (auto j = route.begin()+1; j != route.end(); j++)
         {
             if(.....)
             while(current!=end)
              {
                тут я пишу свой алгоритм , это я уже сделаю
              }
         }
        }
    

    What I need to do is check if there's a point in other routes that I can't do, and I think that in addition to two cycles, something else needs to be added. I've been thinking, and if I don't do vectors, it's a map, but I don't think it's gonna change anything.

    Thank you very much.



  • What is yours? route? Just a cheese vector?

    If you want to find a common point, different The routes, the cycles should follow different routes:

    for (auto i = route1.begin(); i != route1.end(); i++)
        for (auto j = route2.begin(); j != route2.end(); j++)
    

    If it's yours. route Just... vector<int>if Also simple:

    if (*i == *j)
    

    Well, when he does, you'll think about optimizing.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2