Submission #1160153

#TimeUsernameProblemLanguageResultExecution timeMemory
1160153APersonTracks in the Snow (BOI13_tracks)Java
Compilation error
0 ms0 KiB
import java.util.*; public class Tracks { static int n, m, ans = 1; static int[] dx = {0, 0, -1, 1}, dy = {-1, 1, 0, 0}; static char[][] grid; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); m = sc.nextInt(); grid = new char[n][m]; for(int i = 0; i < n; i++) grid[i] = sc.next().toCharArray(); LinkedList<State> q = new LinkedList<>(); q.add(new State(0, 0, 1)); while(!q.isEmpty()) { State cur = q.poll(); ans = Math.max(ans, cur.d); for(int i = 0; i < 4; i++) { int x = cur.x+dx[i]; int y = cur.y+dy[i]; if(x < 0 || x >= n || y < 0 || y >= m || grid[x][y] == '*') continue; if (grid[x][y] != grid[cur.x][cur.y]) q.addLast(new State(x, y, cur.d+1)); else q.addFirst(new State(x, y, cur.d)); grid[x][y] = '*'; } } System.out.println(ans); sc.close(); } public static class State { int x, y, d; public State(int x, int y, int d) { this.x = x; this.y = y; this.d = d; } } }

Compilation message (stderr)

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

=======