Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("graf.in");
- int a[100][100],viz[100],n,ok=1;
- void citire()
- {
- int i,j;
- fin>>n;
- while(fin>>i>>j)
- a[i][j]=a[j][i]=1;
- }
- int dfs(int x,int contor)
- {
- if(contor==0)
- viz[x]=1;
- for(int i=1; i<=n; i++)
- {
- if(viz[i]==0&&a[x][i]==1)
- {
- viz[i]=3-viz[x];
- return dfs(i,++contor);
- }
- if(viz[x]==viz[i]&&a[x][i]==1)
- return 0;
- }
- return 1;
- }
- int main()
- {
- citire();
- cout<<dfs(1,0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement