int dfs(int v){ vis[v] = -1; for(int i = 1; i <= n; i++) { if(a[v][i] != 0 && !vis[i]) { dfs(i); vis[i]=1; } if(a[v][i] != 0 && vis[i] == -1){ printf("YES "); swi=true; return true; } } return false; }
int dfs(int v){ vis[v] = -1; for(int i = 1; i <= n; i++) { if(a[v][i] != 0 && !vis[i]) { dfs(i); vis[i]=1; } if(a[v][i] != 0 && vis[i] == -1){ printf("YES "); swi=true; return true; } } return false; }