/* * hdu1869/win.cpp * Created on: 2012-7-31 * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <deque> #include <list> #include <functional> #include <numeric> #include <cctype> using namespace std; const int SIZE = 105; const int MAX = 0x7fffffff; int mymap[SIZE][SIZE], N; void init() { int i, j; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { mymap[i][j] = MAX; } } } void Floyd() { int i, j, k; for (k = 0; k < N; k++) { for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { if(mymap[i][k] < mymap[i][j] - mymap[k][j]) { mymap[i][j] = mymap[i][k] + mymap[k][j]; } } } } } int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif int M, a, b; while(scanf("%d%d", &N, &M) == 2) { init(); for(int i = 0; i < M; i++) { scanf("%d%d", &a, &b); mymap[a][b] = mymap[b][a] = 1; } Floyd(); bool flag = true; for(int i = 0; i < N; i++) { for(int j = i + 1; j < N; j++) { if(mymap[i][j] > 7) { flag = false; } } } puts(flag ? "Yes" : "No"); } return 0; }