Analysis of the real questions of the Institute of Electronics C/C++ Programming Level Examination December 2022 (Level 5)

All real questions of C/C++ level exam (Level 1~8)・Click here

Question 1: The long road back home

In May 2020, international flight tickets are hard to find. A Chinese student in Washington, USA, must return to Beijing this week for some reasons. Now that we know the flight status between various airports, I want to ask him whether he can come back (regardless of the number of transfers and ticket prices).
Time limit: 1000
Memory limit: 65536
Input
The first line is case Number n (n < 10). In each case, the first line is the number of airports N, N ≤ 10. The following N lines each contain N integers. The j-th (1 ≤ j ≤ N) integer in the i-th (1 ≤ i ≤ N) row represents the lowest fare t (0 < t) of the available flight from the i-th airport to the j-th airport <10000). If unfortunately there is no flight, it is expressed as -1. The i-th integer in the i-th row is 0. The starting point is Washington Dulles International Airport, numbered 1, and the ending point, Beijing Capital International Airport, is numbered N.
Output
One line for each case. Able to return to China, output string: YES. If it is impossible to return to the country, output the string: NO
Sample input
2
3
0 100 -1
-1 0 200
-1 -1 0

Guess you like

Origin blog.csdn.net/gozhuyinglong/article/details/134958107