Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define MOD 1e9 + 7
- #define endl '\n'
- int main()
- {
- ios_base::sync_with_stdio(0); cin.tie(0);
- int n,m;
- cin >> n >> m;
- vector<vector<int> > adj(n);
- for(int i = 0;i < m;i++)
- {
- int a,b;
- cin >> a >> b;
- adj[a].push_back(b);
- adj[b].push_back(a);
- }
- queue<pair<pair<int,int>,int> > q;
- for(int i = 0;i < n;i++)
- {
- while(!q.empty()) q.pop();
- q.push({{i,i},1});
- while(!q.empty())
- {
- int st = q.front().first.first,p = q.front().first.second,sz = q.front().second;
- q.pop();
- if(p==st and sz>1 and sz%2==0){ cout << "Gay found!"; return 0; }
- if(p==st and sz>1) continue;
- for(int i = 0;i < adj[p].size();i++) q.push({{st,adj[p][i]},sz+1});
- }
- }
- cout << "Gay not found!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement