Logo
(追記) (追記ここまで)

26337번 - Sub Matrix Sum 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB94457.143%

문제

You have written many programs to search mazes so matrix search shouldn’t be any different, or will it?

An integer matrix with R rows and C columns has R(R-1)/2 × C(C-1)/2 sub matrices. We want to select a sub matrix with sum (the sum of all integers in it) greater than or equal to a given integer S. We want the size of the sub matrix to be the least possible. The size of a sub matrix is defined as the number of elements in that sub matrix (i.e., number of rows * number of columns in that sub matrix).

입력

The first input line contains a positive integer, t, indicating the number of test cases. The first line of each test case consists of three integers R, C (1 ≤ R ≤ 100,000; 1 ≤ C ≤ 100,000; 1 ≤ R*C ≤ 100,000) and S. Next R lines contain the description of the matrix. Each of these R lines contains C integers separated by a single space. All integers (other than R and C) are between -109 and +109, inclusive.

출력

For each test case, output the size of the minimum sub matrix whose sum is greater or equal to the given S. If there is no such sub matrix, output -1.

제한

예제 입력 1

3
3 3 26
1 2 3
4 5 6
7 8 9
3 3 0
-1 -2 -3
-4 -5 -6
-7 -8 -9
2 2 1
-1 -2
0 2

예제 출력 1

4
-1
1

힌트

출처

University > University of Central Florida > 2013 Local Programming Contest 12번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /