PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000100. Tìm đỉnh trong ma trận (Find a Peak Element II)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tìm đỉnh trong ma trận (Find a Peak Element II)
Find a Peak Element II
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
An entry in an matrix is a peak if it is strictly greater than each existing orthogonally adjacent entry; outside the matrix the value is . Find any zero-based peak coordinate, given that orthogonal neighbors are unequal.
Input
The first line contains . The next lines contain integers each.
Output
Print two integers : the zero-based row and column of any valid peak.
Subtasks
- Subtask 1 (20 points): ; ; orthogonally adjacent entries are unequal.
- Subtask 2 (30 points): ; ; orthogonally adjacent entries are unequal.
- Subtask 3 (50 points): ; ; orthogonally adjacent entries are unequal.
Examples
Input
2 2
1 4
3 2
Output
1 0
Explanation
Cell has value , greater than the adjacent values and , as well as the outer value . Thus 1 0 is valid; 0 1 would also be valid.