#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define Getsign(n) ((n > 0) - (n < 0)) #define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ? true : false) map roma_time = { { "I",1 },{ "II",2 },{ "III",3 },{ "IIII",4 },{ "V",5 },{ "VI",6 },{ "VII",7 },{ "VIII",8 },{ "IX",9 },{ "X",10 },{ "XI",11 },{ "XII",12 } }; typedef vector Ivec; typedef pair pii; int main() { int n, m; scanf("%d %d", &n, &m); vector> graph(n, vector()); for (int i = 0; m > i; i++) { int a, b; scanf("%d %d", &a, &b); a--; b--; graph[a].push_back(b); graph[b].push_back(a); } queue que; array tesu; for (int i = 0; n > i; i++) { tesu[i] = false; } for (int i = 0; graph[0].size() > i; i++) { que.push(graph[0][i]); } while (!que.empty()) { int vertex = que.front(); que.pop(); if (tesu[vertex]) { for (int i = 0; graph[vertex].size() > i; i++) { int tar = graph[vertex][i]; if (tesu[tar]) { printf("YES\n"); return 0; } } } else { for (int i = 0; graph[vertex].size() > i; i++) { tesu[graph[vertex][i]] = true; que.push(graph[vertex][i]); } } } printf("NO\n"); return 0; }