奇怪的MLE
  • 板块学术版
  • 楼主tian_jun_cheng
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/5/15 10:42
  • 上次更新2023/10/28 01:24:27
查看原帖
奇怪的MLE
377434
tian_jun_cheng楼主2022/5/15 10:42
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<queue>
using namespace std;
struct node{
	int a,b,c,t;
};
queue <node> q;
int a,b,c;
void bfs()
{
	node h,t;
	t={a,b,c,0};
	q.push(t);
	while(!q.empty())
	{
		h=q.front();
		q.pop();
		int A=h.a;
		int B=h.b;
		int C=h.c;
		if(A==B && B==C)
		{
			cout<<h.t;
			return;
		}
		if(A<B && A<C)
		{
			t={A+2,B,C,h.t+1};
			q.push(t);
		}
		if(B<A && B<C)
		{
			t={A,B+2,C,h.t+1};
			q.push(t);
		}
		if(C<A && C<B)
		{
			t={A,B,C+2,h.t+1};
			q.push(t);
		}
		if(A<B && C<B)
		{
			t={A+1,B,C+1,h.t+1};
			q.push(t);
		}
		if(A<C && B<C)
		{
			t={A+1,B+1,C,h.t+1};
			q.push(t);
		}
		if(C<A && B<A)
		{
			t={A,B+1,C+1,h.t+1};
			q.push(t);
		}
	}
}
int main()
{
	freopen("same.in","r",stdin);
	freopen("same.out","w",stdout);
	cin>>a>>b>>c;
	bfs();
	return 0;
}

没有数组超出限制啊,为啥会mle啊

2022/5/15 10:42
加载中...