这段为什么会编译错误啊???
  • 板块灌水区
  • 楼主Chalage_2010
  • 当前回复6
  • 已保存回复6
  • 发布时间2025/1/23 09:30
  • 上次更新2025/1/23 11:34:19
查看原帖
这段为什么会编译错误啊???
760690
Chalage_2010楼主2025/1/23 09:30

rt,编译器里是可以编译的,但是提交到洛谷就显示编译失败

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N=1e2+10;
const int INF=0x3f3f3f3f;

int n,m;
int dis[1<<10];
int a[N][N];
signed main()
{
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	
	queue<int> q;
	memset(dis,0x3f,sizeof dis);
	dis[(1<<n)-1]=0;
	q.push((1<<n)-1);
	vector<int> vis(1<<n);
	vis[(1<<n)-1]=true;
	while(!q.empty())
	{
		auto int t=q.front();
		q.pop();
		for(int i=0;i<m;i++)
		{
			int tt=t;
			for(int j=0;j<m;j++)
			{
				if(a[i][j]==1)
				{
					if(t>>j&1)
					{
						tt^=1<<j;
					}
				}
				else if(a[i][j]==-1)
				{
					if(t>>j&1==0)
					{
						tt^=1<<j;
					}
				}
			}
			if(!vis[tt]&&dis[tt]>dis[t]+1)
			{
				vis[tt]=true;
				q.push(tt);
				dis[tt]=dis[t]+1;
			}
		}
		
	}
	if(dis[0]!=INF)
	{
		cout<<dis[(1<<n)-1]<<endl;
	}
	else
	{
		cout<<-1<<endl;
	}
	return 0;
}
2025/1/23 09:30
加载中...