#百度笔试# 百度第二题 通过55 哪个大牛知道原因吗?#include (5488)#include using namespace std;int dx[4] = { -1,0,1,0 }, dy[4] = { 0, 1, 0, -1 };void dfs(vector>&vec,int i,int j,int n) {if ( i = n || j = n||vec[i][j] == -1||vec[i][j]==1)return;vec[i][j] = -1;for (int k = 0; k dfs(vec, i + dx[k], j + dy[k],n);}}int main() {int n;cin >> n;//cin.ignore();vector> vec(n,vector(n));for (int i = 0; i {int m;cin >> m;for (int j = n-1; j >=0; j--) {vec[i][j] = m % 10;m = m / 10;}}int dl = 1;int i = 0, j = 0;while (1) {if (vec[i][j] == 0) {dfs(vec, i, j, n);}if (i == 1 && j == 0)break;int tmpi=i;int tmpj = j;i += dx[dl];j += dy[dl];if (i = n || j = n) {dl = (dl + 1) % 4;i = tmpi + dx[dl];j = tmpj + dy[dl];}}for (int i = 0; i for (int j = 0; j if (vec[i][j] == -1) {vec[i][j] = 0;}elsevec[i][j] = 1;cout }cout }return 0;}