794

This one took me a looong time to figure out the solution, i used dynamic programming approach to modify the bfs traversal. #include <iostream> #include <cstdio> #include <cstdlib> #include <vector> #include <cstring> #include <fstream> #include <string> #include <map> #include <queue> #define INF 100000000 //#define ll long long #define PASS 2 #define NEED 1 #define NONEED