QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#695328 | #6679. Not Another Path Query Problem | monui | Compile Error | / | / | C++23 | 1.6kb | 2024-10-31 19:47:28 | 2024-10-31 19:47:30 |
Judging History
This is the latest submission verdict.
- [2024-10-31 19:47:30]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-31 19:47:28]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
#define no cout<<"No"<<endl
#define yes cout<<"Yes"<<endl
#define int long long
typedef pair<ll,ll>PII;
const int N=1e5+10,M=5e5+10;
int cnt;
int p[N][63];
int f[N];
ll n,m,q,v;
struct node
{
int a,b;
ll 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;
ll 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};
}
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))
{
a=find(a,j),b=find(b,j);
if(a!=b) p[a][j]=b;
}
}
}
vector<int>bit;
for(int i=62;i>=0;i--)
{
if(v&(1ll<<i)) bit.push_back(i);
}
int num=bit.size();
while(q--)
{
int a,b;
cin>>a>>b;
if(!num)//v为0
{
if(get(a)==get(b)) yes;
else no;
continue;
}
int id=0;
bool flag=0;
for(int i=62;i>=0;i--)
{
if(find(a,i)==find(b,i))
{
if(i>bit[id])
{
flag=1;
break;
}
else if(i<bit[id])
{
flag=0;
break;
}
else flag=1,id++;
}
if(id>=num) break;
}
if(flag) yes;
else no;
}
}
int main()
{
ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
int t=1;
// cin>>t;
while(t--)
solve();
return 0;
}
詳細信息
answer.code:7:14: error: ‘ll’ was not declared in this scope 7 | typedef pair<ll,ll>PII; | ^~ answer.code:7:17: error: ‘ll’ was not declared in this scope 7 | typedef pair<ll,ll>PII; | ^~ answer.code:7:19: error: template argument 1 is invalid 7 | typedef pair<ll,ll>PII; | ^ answer.code:7:19: error: template argument 2 is invalid answer.code:12:1: error: ‘ll’ does not name a type 12 | ll n,m,q,v; | ^~ answer.code:16:9: error: ‘ll’ does not name a type 16 | ll w; | ^~ answer.code: In function ‘void solve()’: answer.code:28:14: error: ‘n’ was not declared in this scope 28 | cin>>n>>m>>q>>v; | ^ answer.code:28:17: error: ‘m’ was not declared in this scope 28 | cin>>n>>m>>q>>v; | ^ answer.code:28:20: error: ‘q’ was not declared in this scope 28 | cin>>n>>m>>q>>v; | ^ answer.code:28:23: error: ‘v’ was not declared in this scope 28 | cin>>n>>m>>q>>v; | ^ answer.code:36:17: error: ‘ll’ was not declared in this scope 36 | ll w; | ^~ answer.code:37:28: error: ‘w’ was not declared in this scope 37 | cin>>a>>b>>w; | ^ answer.code:41:32: error: no match for ‘operator=’ (operand types are ‘node’ and ‘<brace-enclosed initializer list>’) 41 | e[++cnt]={a,b,w}; | ^ answer.code:13:8: note: candidate: ‘constexpr node& node::operator=(const node&)’ 13 | struct node | ^~~~ answer.code:13:8: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const node&’ answer.code:13:8: note: candidate: ‘constexpr node& node::operator=(node&&)’ answer.code:13:8: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘node&&’ answer.code:45:46: error: ‘struct node’ has no member named ‘w’ 45 | int a=e[i].a,b=e[i].b,w=e[i].w; | ^ At global scope: cc1plus: error: ‘::main’ must return ‘int’