제출 #1129181

#제출 시각아이디문제언어결과실행 시간메모리
1129181Username_taken12Furniture (JOI20_furniture)Java
컴파일 에러
0 ms0 KiB
import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(r.readLine()); int N = Integer.parseInt(st.nextToken()); int M = Integer.parseInt(st.nextToken()); boolean[][] grid = new boolean[N][M]; int[] dia = new int[N+M-1]; for(int i=0; i<N; i++) dia[i]=Math.min(i+1, M); for(int i=M+N-2; i>=N; i--) dia[i]=Math.min(M+N-1-i, N); for(int i=0; i<N; i++){ st=new StringTokenizer(r.readLine()); for(int j=0; j<M; j++){ if(Integer.parseInt(st.nextToken())==1) update(i,j, grid, dia); } } int Q = Integer.parseInt(r.readLine()); for(int i=0; i<Q; i++) { st = new StringTokenizer(r.readLine()); int x=Integer.parseInt(st.nextToken())-1; int y = Integer.parseInt(st.nextToken())-1; pw.println(((update(x,y,grid,dia)) ? '1' : '0')); } pw.close(); } static boolean update(int i,int j,boolean[][] grid,int[] dia){ if(i<0||i>=grid.length||j<0||j>=grid[0].length) return false; if(grid[i][j]) return true; int d=i+j; if(dia[d]==1) return false; dia[d]--; grid[i][j]=true; if(check(i-1,j+1, grid)){ update(i,j+1, grid, dia); update(i-1, j,grid, dia); } if(check(i+1, j-1,grid)){ update(i, j-1, grid, dia); update(i+1, j, grid, dia); } return true; } static boolean check(int i,int j,boolean[][] grid){ if(i<0||i>=grid.length||j<0||j>=grid[0].length) return true; return grid[i][j]; } }

컴파일 시 표준 에러 (stderr) 메시지

furniture.java:5: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error

=======