求助!奇怪的CE
  • 板块灌水区
  • 楼主Skywalker2187
  • 当前回复17
  • 已保存回复17
  • 发布时间2023/8/27 15:38
  • 上次更新2023/11/3 00:53:28
查看原帖
求助!奇怪的CE
906525
Skywalker2187楼主2023/8/27 15:38
#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;
}

为什么会CE?

本蒟蒻求助各位大佬


编译信息如下↓

[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

2023/8/27 15:38
加载中...