#include #include #include #include #include #include #define rep(i, j) for(int i = 0; i < j; ++i) #define ii pair using namespace std; vector> q; int steps[5100][5100]; int unvisited; bool isIn(int x, int y) { if(x>=0 && x<5001 && y>=0 && y<5001) return true; else return false; } void bfs(int i, int dist) { while(steps[q[i].front().first][q[i].front().second]==dist) { ii pos = q[i].front(); q[i].pop(); int x=pos.first; int y=pos.second; if(isIn(x,y+1) && dist+1>n>>guards; q.resize(n); for(int i=0; i>x>>y; q[i].push({x,y}); steps[x][y] = 0; } unvisited=5001*5001; int dist=0; while(unvisited>0) { for(int i=0; i>x>>y; cout<