QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#118583#4303. New Levelinclude_BMCompile Error//C++141.4kb2023-07-03 17:54:172023-07-03 17:54:18

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-03 17:54:18]
  • 评测
  • [2023-07-03 17:54:17]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read(){
	ll x(0),f(0); char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return f?-x:x;
}

const int N=2e6+10;
int n,m,k,c[N],u[N],v[N],head[N],cnt,vis[N]; ll dis[N];
struct edge{
    int to,nxt,w;
}e[N];
inline void add(int u,int v,int w){
    e[++cnt].to=v,e[cnt].nxt=head[u],e[cnt].w=w,head[u]=cnt;
}

inline int mod(int x){return (x%k+k)%k;}

struct node{
    int x; ll dis;
    node(int _x,ll _dis):x2(_x),dis(_dis){}
    friend bool operator < (node a,node b){return a.dis>b.dis;}
};

signed main(){
	n=read(),m=read(),k=read();
	for(int i=1;i<=n;++i) c[i]=read()-1;
	for(int i=1;i<=m;++i){
        u[i]=read(),v[i]=read();
        add(u[i],v[i],min(mod(c[v[i]]+1-c[u[i]]),mod(c[v[i]]-1-c[u[i]])));
        add(v[i],u[i],min(mod(c[u[i]]+1-c[v[i]]),mod(c[u[i]]-1-c[v[i]])));
    }
    memset(dis,0x3f,sizeof dis);
    priority_queue<node> q; q.emplace(1,0),dis[1]=0;
    while(!q.empty()){
        int u=q.top().x; q.pop(); if(vis[u]) continue; vis[u]=1;
        for(int i=head[u];i;i=e[i].nxt){
            int v=e[i].to;
            if(dis[u]+e[i].w<dis[v]) dis[v]=dis[u]+e[i].w,q.emplace(v,dis[v]);
        }
    }
    for(int i=1;i<=n;++i) c[i]=(c[i]+dis[0]-dis[i])%k,printf("%d ",c[i]+1);
	return 0;
}

Details

answer.code: In constructor ‘node::node(int, long long int)’:
answer.code:24:26: error: class ‘node’ does not have any field named ‘x2’
   24 |     node(int _x,ll _dis):x2(_x),dis(_dis){}
      |                          ^~