QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695387#6679. Not Another Path Query ProblemmonuiCompile Error//C++231.4kb2024-10-31 19:56:072024-10-31 19:56:13

Judging History

This is the latest submission verdict.

  • [2024-10-31 19:56:13]
  • Judged
  • [2024-10-31 19:56:07]
  • Submitted

answer


#include<bits/stdc++.h>
using namespace std;
#define no cout<<"No"<<endl
#define yes cout<<"Yes"<<endl
#define int long long
const int N=1e5+10,M=5e5+10;
int cnt;
int p[N][63];
int f[N];
int n,m,q,v;
struct node
{
	int a,b;
	int w;
}e[M];
int find(int x,int y)
{
	return p[x][y]==x?x:p[x][y]=find(p[x][y],y);
}
int get(int x)
{
	return f[x]==x?x:f[x]=get(f[x]);
}
void solve()
{
	cin>>n>>m>>q>>v;
	for(int k=0;k<=62;k++)
		for(int i=1;i<=n;i++)
			p[i][k]=i;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		int w;
		cin>>a>>b>>w;
		int l=get(a),r=get(b);
		if(l!=r) f[l]=r;
		if(w<v) continue;
		e[++cnt]={a,b,w};
	}
	int bit=0;
	for(int i=0;i<=62;i++){
		if(1ll<<i&v){
			bit=i;
			break;
		}
	}
	for(int i=1;i<=cnt;i++)
	{
		int a=e[i].a,b=e[i].b,w=e[i].w;
		bool flag=true;
		for(int j=62,ans=0;j>=0;j--)
		{
			if(1ll<<j&v){
				ans|=(1ll<<j);
				if((w&ans)!=ans) break;
			}
			if((w&(1ll<<j))&&((!(1ll<<j&v))||(j==bit))
			{
				a=find(a,j),b=find(b,j);
				if(a!=b) p[a][j]=b;
			}
		}
	}

	while(q--)
	{
		int a,b;
		cin>>a>>b;
		int id=0;
		bool flag=false;
		for(int i=62;i>=0;i--)
		{
			if(find(a,i)==find(b,i)){
				yes;
				flag=true;
				break;
			}
		}
		if(!flag) no;
	}
}
signed main()
{
	ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
	return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:59:67: error: expected ‘)’ before ‘{’ token
   59 |                         if((w&(1ll<<j))&&((!(1ll<<j&v))||(j==bit))
      |                           ~                                       ^
      |                                                                   )
   60 |                         {
      |                         ~                                          
answer.code:64:17: error: expected primary-expression before ‘}’ token
   64 |                 }
      |                 ^