The question does not give a data range. If the data is relatively small, hang a table at each point to indicate the feasible path lengths from C to that point. Then start BFS from C and finally make statistics. Point C is the size of the table above. If the data is relatively large, you can consider Tarjan shrinking ring or something...
BSF:
The question does not give a data range. If the data is relatively small, hang a table at each point to indicate the feasible path lengths from C to that point. Then start BFS from C and finally make statistics. Point C is the size of the table above. If the data is relatively large, you can consider Tarjan shrinking ring or something...