WA

2j1ejyu Reply 6 years 5 weeks ago
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); Main obj = new Main(); int row = input.nextInt(); int col = input.nextInt(); int[][] matrix = new int[row][col]; for (int i = 0; i < row; i++) { for(int j=0; j<col; j++) matrix[i][j] = input.nextInt(); } int ans_row = 0; int ans_col = 0; int ans_length = 1; for(int i=0; i<row; i++){ for(int j=0; j<col; j++){ if(matrix[i][j]==1){ for(int k=0; k<=Math.min(row-i-1,col-j-1); k++){ if(obj.all1(matrix, i, j, k)){ if(k+1>=ans_length) { ans_row = i; ans_col = j; ans_length = k+1; } }else break; } } } } System.out.printf("%d %d %d", ans_row, ans_col, ans_length); } public boolean all1(int[][] matrix, int a, int b, int k){ boolean satisfy = true; for(int i=a; i<=a+k; i++){ for(int j=b; j<=b+k; j++){ if(matrix[i][j] != 1) satisfy = false; } } return satisfy; } } 왜 틀렸나요
Hyunwoo Reply 6 years 1 week ago
축하합니다.