import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Scanner; /** * Solution to Random Index Vectors * * @author vanb */ public class rivs_vanb { /** Input. */ private static Scanner sc; /** Output. */ private static PrintStream ps; /** * Read a vector. * * @return the long[] */ private long[] readVector() { int m = sc.nextInt(); long v[] = new long[m]; for( int i=0; ik for i>b int b=0; for( ; b v ) { ps.print( v.size() ); for( Long x : v ) ps.print( " " + x ); ps.println(); } /** * Do it. */ private void doit() { n = sc.nextLong(); k = sc.nextLong(); long[] v1 = readVector(); long[] v2 = readVector(); ArrayList result = new ArrayList(v1.length+v2.length); // Sum int i=0, j=0; while( i Math.abs( v2[j] ) ) { // 0 + 1 = 1, 0 + -1 = -1 result.add( v2[j++] ); } else { // 1 + -1 = 0, -1 + 1 = 0 ++i; ++j; } } // Only one of these will be true while( i