Untitled
unknown
plain_text
a year ago
943 B
2
Indexable
Never
#include<bits/stdc++.h> #define DilligentArch() ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0); #define testcase(t) int t; cin>>t; while(t--) #define pb push_back typedef long long ll; using namespace std; const int N = 1e5+10; vector<int>g[N]; int clr[N]; ll v,e; bool checkdfs(int vertex) { if(clr[vertex]==-1)clr[vertex]=1; for(int child : g[vertex]) { if(clr[child]==-1)clr[child]=1-clr[vertex]; if(!checkdfs(child)) return false; else if(clr[child]==clr[vertex]) return false; } return true; } void solve() { cin>>e; memset(clr,-1,sizeof(clr)); for(ll i=0; i<e; i++) { ll x,y; cin>>x>>y; g[x].pb(y); g[y].pb(x); } if(checkdfs(0))cout<< "BICOLORABLE."<<endl; else cout<< "NOT BICOLORABLE."<<endl; } int main() { // while(cin>>v) { solve(); //} }