QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572666#9319. Bull Farmzjx666Compile Error//C++172.2kb2024-09-18 15:52:512024-09-18 15:52:51

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 15:52:51]
  • 评测
  • [2024-09-18 15:52:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=4010;
int n,l,qi;
int ti[maxn][maxn];
struct A{int x,y,z;
};
A e[2*maxn];//注意两倍 
int head[maxn],ne[maxn*2];//head初始化为-1 
int d[maxn][maxn]; 
int f[maxn];
bool v[maxn];
int id=-1;
int find (int x)
{
	if(x!=f[x])f[x]=find(f[x]);
	return f[x];
}
void add(int x,int y,int z)
{
	e[++id]={x,y,z};
	ne[id]=head[x];
	head[x]=id;
}
priority_queue<pair<int,int> >q;
void dij(int fx)
{
	for(int i=0;i<=n;i++)
	{
		d[fx][i]=1e9+10;
		v[i]=0;
	}
	d[fx][fx]=0;	
	q.push({-d[fx][fx],fx});
	while(q.size())
	{
		while(q.size()&&v[q.top().second])q.pop();
		if(q.empty())break;
		int x=q.top().second;
		v[x]=1;
		q.pop();
		for(int i=head[x];i!=-1;i=ne[i])
		{
			int y=e[i].y;
			if(d[fx][y]>max(d[fx][x],e[i].z))
			{
				d[fx][y]=max(d[fx][x],e[i].z);
				q.push({-d[fx][y],y});
			}
		 } 
	}
}
void build()
{
	bool di[n+10];
	int s=0,t=0;
	for(int i=1;i<=l;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(!di[ti[i][j]])
			{
				di[ti[i][j]]=1;
				s++;
			}
			else 
			{
				di[ti[i][j]]++;
			}
		}//cout<<s<<"!!"<<endl;
		if(s==n)
		{
			
			for(int j=1;j<=n;j++)
			{
				find(j);
				find(ti[i][j]);
				if(f[j]!=f[ti[i][j]])
				{
					f[f[j]]=f[ti[i][j]];
					add(j,ti[i][j],i);
					add(ti[i][j],j,i);
				}
				di[i]=0;
			}
		}
		else if(s==n-1)
		{
			for(int j=1;j<=n;j++)
			{
				if(di[j]==0)
				{
					for(int k=1;k<=n;k++)
					{
						if(ti[i][k]==j)add(k,j,i);
						di[i]=0;
					}
				}
			}
		}
	}
}
signed main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		cin>>n>>l>>qi;
		id=-1;
		for(int i=1;i<=2*n;i++)
		{
		    head[i]=-1;
			f[i]=i;	
		}
		for(int i=1;i<=l;i++)
		{
			for(int j=1;j<=n;j++)
			{
				char x,y;
				cin>>x>>y;
				//cout<<x<<"!"<<y<<"!";
				ti[i][j]=(x-48)*50+y-48;
			}
		}
		build();
		for(int i=1;i<=n;i++)dij(i);
		for(int i=1;i<=qi;i++)
		{
			char x1,y1,x2,y2,x3,y3;
			cin>>x1>>y1>>x2>>y2>>x3>>y3;
			int a=(x1-48)*50+y1-48;
			int b=(x2-48)*50+y2-48;
			int c=(x3-48)*50+y3-48;
			if(d[a][b]<=c)cout<<1;
			else cout<<0;
		}
		cout<<"\n";
	}
	
 } 

详细

answer.code: In function ‘void build()’:
answer.code:68:44: error: use of an operand of type ‘bool’ in ‘operator++’ is forbidden in C++17
   68 |                                 di[ti[i][j]]++;
      |                                 ~~~~~~~~~~~^