Attach a wall at the point of loading map data.
for d in [-1, +1, -WIDTH, +WIDTH]:.https://github.com/nishio/atcoder/blob/master/libs/readMap.py
Addendum in PAST5
PAST5E I used to just read one, but this problem required me to read "two different widths of guard."
PAST5G "Maybe we could make a library of places to graph in terms of adjacencies," he wrote, but we should avoid graphing in the first place.
I made something that reads numpy before. - One-dimensional array with guard
This page is auto-translated from /nishio/地図読み込み時に番兵をつける using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.