import java.util.*; import java.io.*; public abstract class usacotools { public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED = "\u001B[31m"; public static final String ANSI_GREEN = "\u001B[32m"; public static final String ANSI_YELLOW = "\u001B[33m"; public static final String ANSI_BLUE = "\u001B[34m"; public static final String ANSI_PURPLE = "\u001B[35m"; public static final String ANSI_CYAN = "\u001B[36m"; public static final String ANSI_WHITE = "\u001B[37m"; public static int ERRORS=0; public static ArrayList console=new ArrayList(); public static String error="Error"; public static int debugcode=-1; public static boolean isrect(int[][] map,int x,int y) { int cachedsize=-1; int cachey=-1; for(int i=x;icachedsize) { return false; } for(int j=y;jcachey) { return false; } } } return true; } public static Set sclones(Set k) { return (new HashSet(k)); } public static Set sclone(Set k) { return (new HashSet(k)); } public static Set sclonel(Set k) { return (new HashSet(k)); } public static boolean smartequals(int[] a,int[] b) { if(a.length!=b.length) { return false; } for(int i=0;i touching(int[][] map,int x,int y){ ArrayList out=new ArrayList(); try { out.add(map[x-1][y]); }catch(Exception e) { } try { out.add(map[x+1][y]); }catch(Exception e) { } try { out.add(map[x][y-1]); }catch(Exception e) { } try { out.add(map[x][y+1]); }catch(Exception e) { } return out; } public static String repeat(int count, String with) { return new String(new char[count]).replace("\0", with); } public static String changen(int position, char ch, String str){ char[] charArray = str.toCharArray(); charArray[position] = ch; return new String(charArray); } public static BufferedReader mreader(String filen) throws IOException { return new BufferedReader(new FileReader(filen)); } public static PrintWriter mwriter(String filen) throws IOException { return new PrintWriter(new BufferedWriter(new FileWriter(filen))); } public static Scanner getsysscan() { return new Scanner(System.in); } public static int binarySearch(int arr[], int l, int r, int x) { /* * Binary Search * */ if (r>=l) { int mid = l + (r - l)/2; if (arr[mid] == x) return mid; if (arr[mid] > x) return binarySearch(arr, l, mid-1, x); return binarySearch(arr, mid+1, r, x); } return -1; } public static int ebs(int arr[], int l, int r, int x) { Arrays.sort(arr); return binarySearch(arr, l, r, x); } public static int lsearch(int[] a,int b) { for(int i=0;i arr) { int[] stuff=new int[arr.size()]; for(int i=0;i arr) { String[] stuff=new String[arr.size()]; for(int i=0;i",""); int val; try { val=sc.nextInt(); }catch(Exception e) { print("Oops that did not go well please rerun and choose a INTEGER"); val=-1; report(e); print("How about we test erro reporting"); console(); } if(1==val) { } } }