Try every entrance, if it connects to exit, then ans++
if it connects to abysm, then break,
if it connects to another entrance, break and not try that entrance
for example
Code: Select all
1234 (entrance)
////
\\/\
///\
On my method,I think each road only can be searched at most ont time
but when I submit, I got TLE
I tried again and I add "If walked more then one time on a road, break"
I got wrong answer
I think that means my code try to walked more than one time on some roads
I am confused, are there some problems in my method?
Please help me, thanks very much.