Floyd-dijkstra path

After Lin Zhixia finished speaking, she pulled up Jiang Yubai and ran forward.

  The castles and fortresses set as bases by Group A and Group B are all located at high places, and most of the criss-cross tunnels are located at low places.

   Under the interference of Nie Tianqing, the bubble ball rolled into different tunnels. Nie Tianqing shuttled through the tunnel, kicking the ball without any scruples.

Looking at the overall situation, Lin Zhixia concluded: "If we treat this game as a graph theory problem, each node of the tunnel is the apex of the graph. We have 37 vertices in total. This picture has been printed on me. In his mind..."

   "Lin Zhixia!" Jiang Yubai said boldly, "You don't need to explain to me! I believe you!"

   Lin Zhixia dragged him into a tunnel: "You don't want to listen because you don't understand? Then you can only follow me and always follow my instructions."

   For the victory of the entire group, Jiang Yubai forgave Lin Zhixia's provocation.

   They ran to the node of the tunnel and quickly picked up seven balls.

   On the way around, Lin Zhixia ran into Dong Sunqi of the team. Dong Sunqi shouted: "You come with me, here is the shortest way! Only by taking the shortest way can we go back faster!"

   "No!" Lin Zhixia said, "Always choose the shortest path, not necessarily the global optimal solution!"

   Dong Sunqi was shocked: "Damn! What are you talking about!"

Lin Zhixia responded: "Think about the three sides of a triangle! Side a and side b are shorter than side c, and their sum will definitely exceed the length of side c. It's such a simple truth! Why put it in graph theory? I don't understand it!"

   Dong Sun Qihu's body was shocked: "It seems to make sense! You talk a lot, listen to you!"

   So Dong Sunqi and Jiang Yubai both became Lin Zhixia's followers.

   Within a few minutes, they collected twelve bubble balls. However, due to unpredictable circumstances, three people from the enemy team came straight to them.

   Ding Yan ran wildly while yelling: "Gan Shuli, Nie Tianqing! Let's go, go and rob Jiang Yubai! They have a lot of balls! They can pick them up! We don't have to pick them up by ourselves, we just follow them and rob!"

   Jiang Yubai did not panic at all. He stood calmly on the spot and looked at Lin Zhixia calmly: "You must have a way."

   Lin Zhixia's eyes rolled and she said: "I can't help it, let's run! Help, help! Run!"

   "What?" Jiang Yubai was confused and hurriedly followed Lin Zhixia to escape.

   Lin Zhixia laughed and jumped again, the ponytails were scattered. She, Jiang Yubai and Dong Sunqi took the slide one after another and rushed into the trampoline.

   Lin Zhixia ran forward holding four balls, his figure flashed quickly and disappeared into the intricate tunnel.

   Jiang Yubai and Dong Sunqi are at a loss, just like the French army that lost the Maginot line during World War II. Even though they still retain their mobile force, they don't know how to continue fighting.

   "You go through the blue tunnel! Then go through the red tunnel!" Lin Zhixia's voice came from a height, "Hurry up and put the bubble ball into the center area of ​​our group!"

   Jiang Yubai immediately asked: "Where are you going?"

   Lin Zhixia said: "I'm going to find them in Group B."

   "No!" Jiang Yubai stopped, "Lin Zhixia, don't go!"

   Lin Zhixia said goodbye to him: "I'm leaving now! I don't know if I can come back!"

   Jiang Yubai stepped on the entrance of the blue tunnel: "Where are you? I'll save you!"

   Lin Zhixia has decided to go: "No, I can't be a tortoise with a shrunken head! Stay at home, protect the bubble ball, and protect every bubble ball! That is our last hope for victory!"

   Dong Sunqi was also heartbroken: "Lin Zhixia, you go! We will always remember you!"

   "What did you say?" Jiang Yubai began to criticize Dong Sunqi, "We are a group, how can we abandon our companions? Don't you have something to protect in your heart?"

   Dong Sunqi replied decisively: "Yes! I want to protect the bubble ball! Lin Zhixia let us protect the bubble ball, you go to the central area of ​​our group A!"

   The two of them went straight to the center of the A group base.

  *

   Inside the suspended tunnel, Nie Tianqing suddenly said: "There are footsteps, Lin Zhixia is here."

  None of the three members of Nie Tianqing's team ran. They stood still, discussing countermeasures.

   Ding Yan revealed: "Lin Zhixia's nickname in our class is a freak. She is so smart, you have to be careful."

   "She's only ten years old," Nie Tianqing said, "No matter how smart you are, how smart can you be."

   Ding Yan's face changed slightly: "She only takes three seconds to endorse!"

   Nie Tianqing didn't believe it.

   Ding Yan said angrily: "Really! I lied to you to be a puppy!"

   Gan Shuli also said: "Really, she is so smart."

"Don't be aspiring to others and destroy your own prestige," Nie Tianqing taught them like an elder brother. "The opponent is not that terrible. We have three people, and if we play rock-paper-scissors against her, can we not beat her? Every one of us wins. The probability is 50%!"

   "It makes sense!" Lin Zhixia was the one who responded.

   Lin Zhixia followed Nie Tianqing's meaning and said to them: "Fifty percent of the third power is equal to 0.125, and my probability of winning is only 0.125."

   Nie Tianqing asked: "Why is it 0.125?"

Lin Zhixia tilted her head: "I must have beaten each of you. The probability of winning the first time is 0.5, the second time is 0.25, and the third time is 0.125... Isn't that what you said? You assume that the probability of winning in a pairwise match is both It's 0.5..."

   Nie Tianqing frowned: "But, Lin Zhixia, you play stone knife scissors cloth with us, as long as you lose once, you can't continue. Why do you still use the power of 0.5 to calculate the probability?"

"You think so," Lin Zhixia explained patiently, "I play with the three of you, and there will be a total of four results. The first result, I lose in the first game, the probability is 0.5. The second result, I lose in the second game, and the probability is 0.25. The third result, I lose in the third game, the probability is 0.125, and the fourth result, I win the third game, the probability is also 0.125. The sum of these probability events is exactly equal to 1. Do you count? The prerequisite for me to enter the second and third rounds is that I won the last round. However, you have to know that winning the last round is not the final state."

   Nie Tianqing suddenly realized, his right hand made a fist and hammered into the palm of his left hand: "I figured it out."

   He turned his head and looked at the two companions: "Happy! We have a probability of 0.875 to win!"

   Ding Yan trembled: "Nie Tianqing, she said so much, do you think you can win by yourself? She must have lied to you. I don't believe it."

   Nie Tianqing bypassed Ding Yan. He walked towards Lin Zhixia and said with a wary spirit: "Go ahead, Lin Zhixia, stone knife scissors cloth."

   Lin Zhixia should be happy.

   Then, the two of them made moves at the same time-Nie Tianqing took out the stone, and Lin Zhixia took out the cloth.

   Nie Tianqing was shocked and freezed in place.

   Lin Zhixia clapped both hands and jumped in front of Ding Yan.

   Ding Yan's heart was terrified. He bit his head and showed the scissors, while Lin Zhixia was a rock. Ding Yan had an expression of "I already knew" and began to count down the frozen seconds of three minutes.

   From the Ding Yan group, there is only one Gan Shuli left.

   The hope of the whole group is pinned on Gan Shuli.

   Gan Shuli said, "I...rock-scissors..."

   "Gan Shuli," Lin Zhixia patted her shoulder, "Don't be nervous."

   The tunnel node is a closed space. There is a glass window on the left and right sides, and there are vents on the top. Gan Shuli looks out and can see the trampoline, zipline, and chandeliers. She turned her mind to face Lin Zhixia: "Lin Zhixia! Rock, paper, scissors!"

   After speaking, she spread out her five fingers to form a "cloth" shape.

   And Lin Zhixia's move seems to be earlier than Gan Shuli. She was already a scissor hand long before Gan Shuli could react.

   Gan Shuli was surprised: "You... won again."

   Lin Zhixia smiled and said, "Oh, it's all luck."

   Lin Zhixia thought in her heart—it was all luck that made her born different from everyone else. Through various detailed observations, she can predict the behavior of every classmate.

   Gan Shuli applauded her: "Good luck."

   "I told you!" Ding Yan warned Nie Tianqing, "I knew it! We can't beat her!"

   Nie Tianqing turned over the old account: "You already knew, why did you take us to rob Lin Zhixia and the group?"

   Ding Yan was blocked and speechless. He just couldn't understand the happy look of Jiang Yubai following Lin Zhixia to pick up the ball easily. In just a few minutes, picked up a bunch of balls! Why! Why doesn't Jiang Yubai need to use his brain! He doesn't want to use his brain either!

   Pity the three of them in the group, they were all frozen in place.

   Lin Zhixia ran away long ago.

   On the way back to the base, Lin Zhixia was still picking up the ball. She was so happy, her hair was loose and draped over her shoulders like a little madman. But she didn't care at all. She picked up four balls and rushed into a tunnel, just in time for a collision with Jiang Yubai.

   Lin Zhixia fell on the spot.

   Jiang Yubai knelt on the ground, supporting her with both hands.

   She said in a daze: "The four bubble balls have all rolled away, go pick them up..."

   Jiang Yubai only asked her: "Sorry, did I hurt you? I have a doctor at home."

   Lin Zhixia shook his head: "No." Then he asked: "Why do you want to say sorry to me? I bumped into you too. You didn't mean it. The effect of force is mutual."

   A red hair rope hangs from the end of Lin Zhixia's hair. Jiang Yubai gently took off her hair rope: "You tie up your hair. In the tunnel, your hair can't block your eyes. You must see the route clearly."

   Lin Zhixia has picked up three bubble balls. She sat on the ground with her back facing Jiang Yubai: "You help me tie my hair! Hurry up!"

   Jiang Yubai was startled: "I...I don't know how to tie my hair."

   Lin Zhixia immediately threw the bubble ball into his arms and snatched the red hair rope from his hand. She tied up her long hair while chanting: "Tie hair is very simple."

   Jiang Yubai said: "I haven't studied."

   Lin Zhixia told him: "There are many things that are so simple that you don't need to learn. You only need to take a look and you can master them."

  Dong Sunqi in the distance let out an earth-shattering roar: "Jiang Yubai! Lin Zhixia! Where are you!"

   "Go!" Lin Zhixia pulled Jiang Yubai up, "We continue to pick up the ball!"

   Jiang Yubai asked her: "Are you still using the shortest path algorithm?"

Lin Zhixia looked back at him and ran forward with him: "Of course! I have a Floyd algorithm matrix in my mind! All tunnel nodes are the vertices of the graph. When the matrix doesn't work, I will build a Dijkstra tree. , This tree also grows in my mind. In fact, to put it bluntly, it is the fusion of greedy, exhaustive and pruning algorithms. It is as simple as tying your hair. No need to think, just look at it! I will take you the fastest Way! Let's go home together!"

   Jiang Yubai couldn't help admiring her. Hearing her say "I will take you the fastest way, let's go home together", Jiang Yubai is very happy, this time they will win Group A!

   The road in the tunnel is rugged. Jiang Yubai and Lin Zhixia each carry four balls. Jiang Yubai peeped at the enemy's movement and said strangely: "They will not chase us anymore."

   Lin Zhixia laughed: "They will go to the center of our Group A base and rob Dong Sunqi. We have to run back to the center of the Group A base as soon as possible before they attack!"

   "What!" Jiang Yubai accused, "They are sinister!"

   Lin Zhixia comforted him: "Don't be afraid! I will protect you!"

   She jumped onto a pipe.

   Jiang Yubai put all the four balls in his arms into the pipe. Then, he held the ring with one hand, stood at the start of the zipline track, turned his head and said to Lin Zhixia: "You go back to the base first! I saw two balls on the trampoline!"

   Lin Zhixia told him: "Be careful, go and come back!"

   Jiang Yubai flew to the ground like a gust of wind. He leaped and landed on the trampoline, his footwork very steady. His landing posture is also very skillful, by rolling in place to reduce the buffer, the trampoline does not even move up and down.

   He picked up the precious bubble ball and looked up at Lin Zhixia on the castle.

   Lin Zhixia stood by the window of the castle, stretched out a hand, and waved at him.

   Jiang Yubai remembered the fairy tale books he had read—the princess always stood on the castle, waiting for the prince to slaughter the demons, and waiting for the prince to rescue her.

   And the princess in front of him is different.

   The princess in front of me is more like a prince overcoming thorns than him.

   The story in the fairy tale book is wrong. According to his own eyes, the princess can also be invincible and brave the waves.