diff --git a/main.java b/main.java index 2ab2e9a..aca65e9 100644 --- a/main.java +++ b/main.java @@ -15,14 +15,22 @@ class main { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String s; ArrayList> grid = new ArrayList>(); + HashMap hunted = null; while ((s = in.readLine()) != null && s.length() != 0) { - if(s.startsWith("#")) continue; - ArrayList row = new ArrayList(); - for ( char c : s.toLowerCase().toCharArray() ) { - row.add(new Character(c)); + if(s.startsWith("#")) { + hunted = new HashMap(); + String[] hunted_input = s.split("\\s+"); + for ( int i=1; i row = new ArrayList(); + for ( char c : s.toLowerCase().toCharArray() ) { + row.add(new Character(c)); + } + grid.add(row); } - grid.add(row); } // for ( ArrayList row : grid ) { @@ -34,7 +42,16 @@ class main { Prison prison = new Prison(grid); System.out.println(prison); - System.out.println(prison.search(words)); + ArrayList found = prison.search(words); + for ( String w : found ) { + if(hunted != null) { + if( hunted.containsKey(new Integer(w.length())) ) { + System.out.println(w); + } + } else { + System.out.println(w); + } + } // System.out.println(prison.getNeighbours(prison.getCell(0,2))); }