Returns the shortest distance between two points.
// Memset (MAP, 0x1ffffff, sizeof (MAP); // The initialization method is incorrect.
The correct method for using memset is that the initial value is an 8-digit value. For example, memset (MAP, 0x3f, sizeof (MAP); If map is of the int type, it is initialized to four 3f, namely 0x3f3f3f3f.
# Include <iostream> using namespace STD; # define n 105int n, m; int map [N] [N]; void Floyd () {for (INT I = 0; I <n; I ++) for (Int J = 0; j <n; j ++) for (int K = 0; k <n; k ++) {If (Map [J] [I] + map [I] [k] <map [J] [k]) map [J] [k] = map [J] [I] + map [I] [k] ;}} int main () {While (~ Scanf ("% d", & N, & M) {// memset (MAP, 0x1ffffff, sizeof (MAP )); // incorrect Initialization Method for (INT I = 0; I <n; I ++) for (Int J = 0; j <n; j ++) map [I] [J] = 0x1fffff; int X, Y; For (INT I = 0; I <m; I ++) {scanf ("% d ", & X, & Y); map [x] [Y] = map [y] [x] = 1 ;}for (INT I = 0; I <N; I ++) map [I] [I] = 0; Floyd (); int flag = 0; For (INT I = 0; I <n & flag = 0; I ++) {for (Int J = 0; j <n; j ++) {If (Map [I] [J]> 7) {flag = 1; break ;}}if (flag = 1) cout <"no" <Endl; else cout <"yes" <Endl;} return 0 ;}