Programming contests

DEIK Regionális Programozó Csapatverseny, egyetemi kategória, 2025. december 7.

December 7, 2025, 10:30 AM – December 7, 2025, 3:30 PM

matrix-1

We need to walk on the cells of an MM matrix, starting from any chosen starting cell. We can move to a horizontally or vertically adjacent cell, but only if the adjacent cell’s value is greater than the one we’re standing on. What is the maximum number of steps we can take (SS)? How many cells are there from which we can take the maximum possible number of steps (LL)?

Input specification

TT is the number of test cases. Description of a test case: First line: RR and CC (number of rows and columns of the matrix). Then RR lines follow, each containing CC integers.

Output specification

TT lines, each containing the requested numbers SS and LL.

Constraints

1T1001\le T \le 100
1R1001\le R \le 100
1C1001\le C \le 100
1M1_0001\le M \le 1\_000

Sample input 1

  1. 4
  2. 2 2
  3. 1 1
  4. 2 4
  5. 3 3
  6. 1 2 3
  7. 2 3 4
  8. 3 4 5
  9. 5 5
  10. 1 2 3 2 1
  11. 1 2 4 2 1
  12. 1 3 5 3 1
  13. 3 5 6 5 3
  14. 3 5 7 5 3
  15. 5 5
  16. 1 1 1 1 1
  17. 1 2 2 2 1
  18. 1 2 3 2 1
  19. 1 2 2 2 1
  20. 1 1 1 1 1
download as text file

Sample output 1

  1. 2 1
  2. 4 1
  3. 6 2
  4. 2 4
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024