시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB52266.667%

문제

Consider a positive integer X and an N by N matrix A with positive integer entries. Determine the minimum area of a continuous submatrix for which the bitwise or of all its elements equals X.

입력

The standard input contains on the first line integers X and N, separated by a space. On the following N lines there are N positive integers separated by spaces representing a matrix line

출력

The standard output will contain a positive integer representing the minimum area of the submatrix.

제한

  • 2 ≤ N ≤ 500
  • 1 ≤ A[i][j] < 231
  • The bitwise or of two positive integers is the integer whose ith bit equals 0 if and only if the ith bit of both integers is 0.
  • It is guaranteed that for all input data there will always be a solution and the minimum area will be at least 2.

서브태스크

번호 배점 제한
1 14

N ≤ 10, 1 ≤ A[i][j] < 256

2 18

11 ≤ N ≤ 35, 1 ≤ A[i][j] < 256

3 21

36 ≤ N ≤ 100, 1 ≤ A[i][j] ≤ 65536

4 26

101 ≤ N ≤ 250, 1 ≤ A[i][j] ≤ 65536

5 21

251 ≤ N ≤ 500, 1 ≤ A[i][j] < 231

예제 입력 1

11 4
5 9 1 8
7 7 3 1
2 3 1 9
5 5 8 7

예제 출력 1

3

채점 및 기타 정보

  • 예제는 채점하지 않는다.