#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define x first
#define y second
const int N=1e3+10;
typedef pair<int,int> PII;
using namespace std;
int n;
int maze[N][N];
PII pre[N][N];
void bfs(int xPos,int yPos){
PII t(xPos,yPos);
while(pre[0][0].x==-1&&pre[0][0].y==-1){
for(int i=t.x-1;i<=t.x+1;i++){
for(int j=t.y-1;j<=t.y+1;j++){
if(i==t.x&&j==t.y)
continue;
if(i<0||i>=n||j<0||j>=n)
continue;
if(maze[i][j]==1||(pre[i][j].x==-1||pre[i][j].y==-1))
continue;
pre[i][j]={t.x,t.y};
}
}
}
}
int main(){
memset(pre,-1,sizeof(pre));
scanf("%d",&n);
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
scanf("%d",&maze[i][j]);
bfs(n-1,n-1);
for(int i=0,j=0;i!=n-1&&j!=n-1;i=pre[i][i].x,j=pre[i][j].y)
printf("%d %d\n",i,j);
return 0;
}
本蒟蒻求助各位大佬
[Error] 'pair' does not name a type
[Error] 'PII' does not name a type
In function 'void bfs(int, int)':
[Error] 'PII' was not declared in this scope
[Error] 'pre' was not declared in this scope
[Error] 't' was not declared in this scope
[Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11
In function 'int main()':
[Error] 'pre' was not declared in this scope