(SPOJ) Caça ao tesouro - Solution
Link to the problem: http://br.spoj.com/problems/TESOUR11/ For each clue that we have, we need to know all its possible ends. Moreover, in each possible end we keep a counter associated with how many clues move us to that position. Then, we know how to determine for sure where the treasure is if there is only one position where the counter is equal to the number of clues. import java.io.*; import java.util.*; class Main { public int[] vi = {-1,0,0,1}; public int[] vj = {0,-1,1,0}; public void process() throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); String[] s = line.split("\\s"); int size = Integer...