Submission #666556

#TimeUsernameProblemLanguageResultExecution timeMemory
666556achejakhangTracks in the Snow (BOI13_tracks)Java
Compilation error
0 ms0 KiB
import java.util.*; import java.io.*; public class Testing { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer in = new StringTokenizer(br.readLine()); int h = Integer.parseInt(in.nextToken()), w = Integer.parseInt(in.nextToken()); char[][] grid = new char[h][w]; for (int i=0; i< h; i++) grid[i] = br.readLine().toCharArray(); ArrayDeque<Integer> nextRow = new ArrayDeque<>(); ArrayDeque<Integer> nextHeight = new ArrayDeque<>(); ArrayDeque<Integer> nextValue = new ArrayDeque<>(); nextRow.addLast(0); nextHeight.addLast(0); nextValue.addLast(1); int maxV = 1; while (!nextRow.isEmpty()) { int r = nextRow.removeFirst(), c = nextHeight.removeFirst(), v = nextValue.removeFirst(); maxV = Math.max(maxV, v); if (r < h-1 && grid[r+1][c] != '.') { if (grid[r+1][c]==grid[r][c]) { nextRow.addFirst(r+1); nextHeight.addFirst(c); nextValue.addFirst(v); } else { nextRow.addLast(r+1); nextHeight.addLast(c); nextValue.addLast(v+1); } } if (r > 0 && grid[r-1][c] != '.') { if (grid[r-1][c]==grid[r][c]) { nextRow.addFirst(r-1); nextHeight.addFirst(c); nextValue.addFirst(v); } else { nextRow.addLast(r-1); nextHeight.addLast(c); nextValue.addLast(v+1); } } if (c < w-1 && grid[r][c+1] != '.') { if (grid[r][c+1]==grid[r][c]) { nextRow.addFirst(r); nextHeight.addFirst(c+1); nextValue.addFirst(v); } else { nextRow.addLast(r); nextHeight.addLast(c+1); nextValue.addLast(v+1); } } if (c > 0 && grid[r][c-1] != '.') { if (grid[r][c-1]==grid[r][c]) { nextRow.addFirst(r); nextHeight.addFirst(c-1); nextValue.addFirst(v); } else { nextRow.addLast(r); nextHeight.addLast(c-1); nextValue.addLast(v+1); } } grid[r][c] = '.'; } out.println(maxV); br.close(); out.close(); } }

Compilation message (stderr)

tracks.java:4: error: class Testing is public, should be declared in a file named Testing.java
public class Testing {
       ^
1 error