Or

X와 N×N 행렬이 주어질 때, 원소 전체의 비트 OR이 X가 되는 연속 부분행렬의 최소 넓이를 구한다.

어려움8비트 연산투 포인터누적 합행렬아직 제출이 없습니다시간 제한5초메모리 제한512 MB

문제

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.