#CCBCHBON0000031. Thoát hai vòng bằng cờ (Exit Two Loops With a Flag)
Thoát hai vòng bằng cờ (Exit Two Loops With a Flag)
Exit Two Loops With a Flag
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Read an r-by-c integer grid in row-major order. Print the 1-based row and column of the first negative value, or -1 -1 if absent. No matrix allocation is needed.
Input
Two integers r,c, followed by exactly r*c integers in [-100,100], row-major; 1<=r,c<=100.
Output
Print two 1-based indices separated by a space.
Subtasks
-
Subtask 1 (20%): ; .
-
Subtask 2 (30%): ; .
-
Subtask 3 (50%): ; .
Examples
Example 1
Input:
2 2
1 2
-3 4
Output:
2 1
Explanation:
Indices start at 1 and are checked row-major; no negative means -1 -1. Result: 2 1.
Example 2
Input:
1 3
1 0 2
Output:
-1 -1
Explanation:
Indices start at 1 and are checked row-major; no negative means -1 -1. Result: -1 -1.
Example 3
Input:
2 2
1 2
3 -4
Output:
2 2
Explanation:
Indices start at 1 and are checked row-major; no negative means -1 -1. Result: 2 2.