#include <atcoder/dsu>
using namespace atcoder;
bool is_connected(VV& G){
ll N = G.size();
dsu uf(N);
rep(i,N){
for(ll to : G[i]){
uf.merge(i,to);
}
}
if(uf.groups().size()==1)return true;
return false;
}
bool is_eular_circuit(VV& G){
ll N = G.size();
VI in(N);
VI out(N);
rep(i,N){
for(ll j : G[i]){
out[i]++;
in[j]++;
}
}
rep(i,N){
if(in[i]!=out[i])return false;
}
return true;
}
bool is_eular_trail(VV& G){
ll N = G.size();
VI in(N);
VI out(N);
rep(i,N){
for(ll j : G[i]){
out[i]++;
in[j]++;
}
}
ll more_in=0;
ll more_out=0;
ll even=0;
rep(i,N){
if(in[i]==out[i]){
even++;
}
else if(in[i]==out[i]+1){
more_in++;
}
else if(in[i]+1==out[i]){
more_out++;
}
else{
return false;
}
}
if(more_in==1 && more_out==1)return true;
return false;
}
条件確認