← 返回 tesla 的题目列表Find First Fit for Solar Panel in Grid
类型:online_judge
Given a 2D grid of 0s and 1s, and a solar panel's height and width, find the first coordinate where the panel can fit. 0 means empty, 1 means blocker.
Input Format
The first line contains two integers n and m (1 ≤ n, m ≤ 100) representing grid rows and columns.
The next n lines each contain m integers representing the grid state (0 or 1).
The last line contains two integers h and w (1 ≤ h ≤ n, 1 ≤ w ≤ m) for the solar panel's height and width.
Output Format
Output two integers i and j if there exists a suitable starting top-left coordinate (0-based), or -1 -1 if none exists.
Example
Input
3 3
0 0 0
0 0 1
1 1 0
2 2
Output
0 0
Constraints
Up to 20% of the grid points can be blockers.
Example
Input
3 3
0 0 0
0 0 1
1 1 0
2 2