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

escape-1

We need to escape from a maze in at most S steps. The maze contains: 0-marked freely passable cells. ^v<>-marked free cells - for these, we can only enter from a specific direction: only from below,above,from the right,from the left respectively. But we can exit in any direction (following the rules). 1-marked forbidden cells: cannot step on them, cannot start from them In one move, we can step to a horizontally or vertically adjacent free cell. If we reach the edge of the maze, we have escaped… Determine how many internal (not on the edges) free cells (EE) exist such that starting from there, we can escape within SS steps.

Input specification

The first line contains TT, the number of mazes. Description of a maze: First line: three numbers SRCS~~ R~~ C~~ (maximum steps, rows, columns). Then RR lines follow: each containing a string of length CC with the characters described above.

Output specification

TT lines, each containing the requested number EE.

Constraints

1T151\le T \le 15
1S2001\le S \le 200
3R1003\le R \le 100
3C1003\le C \le 100

Sample input 1

  1. 5
  2. 2 4 4
  3. 1111
  4. 1001
  5. 1011
  6. 0v11
  7. 2 4 4
  8. 1111
  9. 1001
  10. 1011
  11. 0>11
  12. 1 4 4
  13. 1001
  14. 1001
  15. 1011
  16. 0v11
  17. 3 5 5
  18. 00100
  19. 00^00
  20. 1<0>1
  21. 00v00
  22. 00100
  23. 6 5 5
  24. 00100
  25. 00^00
  26. 1<0>1
  27. 00v00
  28. 00100
download as text file

Sample output 1

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