package yukicoder168; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); long[] x=new long[n]; long[] y=new long[n]; for(int i=0;if[y]){ int d=x; x=y; y=d; } f[x]+=f[y]; f[y]=x; } return x!=y; } int root(int x){ return f[x]<0?x:root(f[x]); } int count(){ int cnt=0; for(int d:f){ if(d<0)cnt++; } return cnt; } } }