P1341 无序字母对
推荐一道好题
欧拉(通路)路径即仅有两个入度出度之和为奇数的点
欧拉回路即所有点入读和出度之和为偶数
可用DFS搜索遍历一遍,并在遍历时每遍历一条边就删除一条边
所有边删完后即欧拉路的逆序倒序输出即可、
好题部分代码
void dfs(int last) { // if(cnt==n+1)return; for(int i=1;i<53;i++) if(G[last][i]==1) { G[last][i]=G[i][last]=0; dfs(i); } ans[++cnt]=last; }