A directed graph has Euler's path:
In a directed graph, if the graph is weakly connected and two vertices are exceeded, the inbound degrees of all other vertices are equal to the outbound degrees, one point has one more degree of entry than the degree of exit, and the other has one less degree of entry. This graph has an Euler's path, which is a sufficient condition.
In this question, you also need to determine whether the connection is established. You can use the query set records to determine whether the connection is established.
#include
#include
#include
using namespace std;int in[50],out[50];int root[50];void init(){for(int i=0;i<=25;i++){root[i]=i;}}int find(int x){int temp=root[x];if(x==root[x]) return x;else{return root[x]=find(root[x]);}}int main(){int t;scanf("%d",&t);while(t--){int n,i;init();memset(in,0,sizeof(in));memset(out,0,sizeof(out));char s[2000];scanf("%d",&n);getchar();for(i=0;i