编译不过去……
  • 板块灌水区
  • 楼主LIANZHENG_SCHOOL
  • 当前回复13
  • 已保存回复13
  • 发布时间2021/6/23 21:37
  • 上次更新2023/11/4 21:34:35
查看原帖
编译不过去……
349033
LIANZHENG_SCHOOL楼主2021/6/23 21:37
#include <iostream>
#include <queue>
using namespace std;
int a[11],b[30]={},sum=0,cs=0;
int wt[11][5]={{0},{1,2,4,5,0},{1,2,3,0,0},{2,3,5,6,0},{1,4,7,0,0},{2,4,5,6,8},{3,6,9,0,0},{4,5,7,8,0},{7,8,9,0,0},{5,6,8,9,0}};
bool vis[5][5][5][5][5][5][5][5][5]={};
struct w{
	int hh[11];
	int oo[30];
	int n;
};
queue<w>q;
bool ch(w c) {
	for(int i=1 ;i<=9 ;i++) {
		if(c.hh[i]!=0) {
			return false;
		}
	}
	return true;
}
w mv(w f,int n) {
	for(int i=0 ;i<5 ;i++) {
		f.hh[wt[n][i]]=(f.hh[wt[n][i]]+3)%4;
	}
	f.n++;
	f.oo[f.n]=n;
	return f;
}
void bfs() {
	q.push(w{a,b,0});		//这里哦
	w next,now;
	while(!q.empty()) {
		now=q.front();
		q.pop();
		for(int i=1 ;i<=9 ;i++) {
			next=mv(now,i);
			if(ch(next)) {
				for(int j=1 ;j<=now.n ;j++) {
					cout<<now.oo[j];
				}
				cout<<i<<endl;
				return ;
			}
			if(vis[next.hh[1]][next.hh[2]][next.hh[3]][next.hh[4]][next.hh[5]][next.hh[6]][next.hh[7]][next.hh[8]][next.hh[9]]) {
				continue;
			}
			vis[next.hh[1]][next.hh[2]][next.hh[3]][next.hh[4]][next.hh[5]][next.hh[6]][next.hh[7]][next.hh[8]][next.hh[9]]=true;
			q.push(next);
		}
	}
}
int main() {
	for(int i=1 ;i<=9 ;i++) {
		cin>>a[i];
		a[i]%=4;
	}
	bfs();
	return 0;
}

Dev和洛谷都编译不过去啊……

2021/6/23 21:37
加载中...