Created
May 6, 2020 07:34
-
-
Save anantbahuguna/d505abdf9022c79396e633997251fbac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
vector<pair<int,int> > vpairs; | |
int main() | |
{ | |
//write your code here | |
int n,m; | |
cin>>n>>m; | |
while(m--) | |
{ | |
int a,b; | |
cin>>a>>b; | |
vpairs.emplace_back(a,b); | |
} | |
for(int x: {vpairs[0].first,vpairs[0].second}) | |
{ | |
vector<int> val(n+1); | |
int all = 0; | |
for(auto c: vpairs) | |
{ | |
if(c.first != x && c.second != x) | |
{ | |
val[c.first]++; | |
val[c.second]++; | |
all++; | |
} | |
} | |
if(*max_element(val.begin(),val.end()) == all) | |
{ | |
cout<<"YES\n"; | |
return 0; | |
} | |
} | |
cout<<"NO\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment