QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#545415#5073. Elden RingtaiyuuCompile Error//C++141.5kb2024-09-03 11:58:452024-09-03 11:58:46

Judging History

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

  • [2024-09-03 11:58:46]
  • 评测
  • [2024-09-03 11:58:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int re(){
	int num=0,fl=1;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') fl=-1;ch=getchar();}
	while(isdigit(ch)){num=num*10+ch-'0';ch=getchar();}
	return num*fl;
}
const int N=2e5+100;
const int M=4e5+100;
int n,m,T,tu,tv,head[N],nxt[M],ver[M],dis[N],c[N],tot=1,a,b; 
void adde(int tu,int tv){
	nxt[++tot]=head[tu];
	head[tu]=tot;
	ver[tot]=tv;
}
void sol1(){
	queue<int> q;
	q.push(1);dis[1]=0;
	while(!q.empty()){
		int x=q.front();q.pop();
		if(x==n){
			cout<<dis[n]<<"\n";return;
		}
		for(int i=head[x];i;i=nxt[i]){
			int y=ver[i];
			if(dis[y])	continue;
			if(c[1]+a*dis[x]>c[y]+(dis[x]+1)*b){
				dis[y]=dis[x]+1;
				q.push(y);
			}
			else
				dis[y]=-1;
		}
	}
	cout<<-1<<"\n";
	return ;
}
void sol2(){
	priority_queue<pair<int,int> > q;
	q.push(make_pair(0,1));dis[1]=0;
	while(!q.empty()){
		int x=q.top().second;q.pop();
		for(int i=head[x];i;i=nxt[i]){
			int y=ver[i];
			if(dis[y])	continue;
			dis[y]=max(dis[x]+1,max(0,(c[y]-c[1]+a)/(a-b)+1);
			q.push(make_pair(-dis[y],y));
		}
	}
	sort(dis+1,dis+n);
	for(int i=1;i<dis[n];++i){
		if(i<dis[i+1]){
			cout<<"-1\n";return;
		}
	}
	cout<<dis[n]<<"\n";
	return ;
}
int main(){
	T=re();
	while(T--){
		for(int i=1;i<=n;++i)
			head[i]=dis[i]=0;
		for(int i=1;i<=m;++i)
			nxt[i]=ver[i]=0;
		n=re();m=re();a=re();b=re();
		for(int i=1;i<=m;++i){
			tu=re();tv=re();
			adde(tu,tv);adde(tv,tu);
		}
		for(int i=1;i<=n;++i)
			c[i]=re();
		if(a<=b)	sol1();
		else	sol2();
	}
	return 0;
}

Details

answer.code: In function ‘void sol2()’:
answer.code:48:73: error: expected ‘)’ before ‘;’ token
   48 |                         dis[y]=max(dis[x]+1,max(0,(c[y]-c[1]+a)/(a-b)+1);
      |                                   ~                                     ^
      |                                                                         )