Analysis of C/C++ (level five) real questions in December 2022#中国电子学院#National Youth Software Programming Level Examination

insert image description here

C/C++ Programming (Level 1~8) All real questions・Click here

Question 1: The long journey back home

In May 2020, international flight tickets are hard to come by. A Chinese student studying in Washington DC must return to Beijing within this week due to some reasons. Now that the flight situation between various airports is known, ask him if he can come back (regardless of the number of transfers and ticket prices).
Time limit: 1000
Memory limit: 65536
Input
The first row contains the number of cases n (n < 10). For each case, the first row is the number of airports N, N ≤ 10. After N lines, each line contains N integers. The j-th (1 ≤ j ≤ N) integer in the i-th (1 ≤ i ≤ N) row represents the lowest fare t of the available flight from the i-th airport to the j-th airport (0 < t < 10000). If unfortunately there is no flight, then use -1 to indicate. The i-th integer in the i-th row is 0. The starting point of Washington Dulles International Airport is numbered 1, and the ending point of Beijing Capital International Airport is numbered N.
Output
one line per case. Able to return to China, output string: YES. If you cannot return to your country, output a string: NO
Example input
2
3
0 100 -1
-1 0 200
-1 -

Guess you like

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