F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

View Compilation Error

0_0_20611036_29467.cpp:8:5: error: 'a' does not name a type
     a.cost;    }};struct E{    int v,to,dist;} edg[M*20];vector<int>G[M];void addedge(int u,int v,int dist){    edg[num].v=v;    edg[num].dist=dist;    edg[num].to=head[u];    head[u]=num++;}void init(){    num=0;    memset(head,-1,sizeof(head));    memset(val,0,sizeof(val));    for(int i=0; i<n; i++)        G[i].clear();}void bfs(){    for(int i=0; i<n; i++)        for(int j=0; j<=cap; j++)            dp[i][j]=0;    priority_queue<node> q;    q.push((node){s,0,0});    while(!q.empty())    {        node x=q.top();        q.pop();        int u=x.u,cost=x.cost,res=x.res;        if(u==e)        {            printf("%d\n",cost);            return ;        }        if(res<cap&&(dp[u][res+1]==0||dp[u][res+1]>cost+val[u]))        {            dp[u][res+1]=cost+val[u];            q.push((node){u,dp[u][res+1],res+1});        }        for(int i=head[u]; i!=-1; i=edg[i].to)        {            int v=edg[i].v,dist=edg[i].dist;            if(res<dist)continue;            if(dp[v][res-dist]==0||dp[v][res-dist]>cost)            {                dp[v][res-dist]=cost;                q.push((node){v,cost,res-dist});            }        }    }    printf("impossible\n");    return ;}int main(){    while( scanf("%d%d",&n,&m)!=EOF)    {        init();        for(int i=0; i<n; i++)            scanf("%d",&val[i]);        int a,b,c;        for(int i=1; i<=m; i++)        {            scanf("%d%d%d",&a,&b,&c);            addedge(a,b,c);            addedge(b,a,c);        }        int q;        scanf("%d",&q);        while(q--)        {            scanf("%d%d%d",&cap,&s,&e);            bfs();        }    }    return 0;}
     ^
0_0_20611036_29467.cpp:8:16: error: expected declaration before '}' token
     a.cost;    }};struct E{    int v,to,dist;} edg[M*20];vector<int>G[M];void addedge(int u,int v,int dist){    edg[num].v=v;    edg[num].dist=dist;    edg[num].to=head[u];    head[u]=num++;}void init(){    num=0;    memset(head,-1,sizeof(head));    memset(val,0,sizeof(val));    for(int i=0; i<n; i++)        G[i].clear();}void bfs(){    for(int i=0; i<n; i++)        for(int j=0; j<=cap; j++)            dp[i][j]=0;    priority_queue<node> q;    q.push((node){s,0,0});    while(!q.empty())    {        node x=q.top();        q.pop();        int u=x.u,cost=x.cost,res=x.res;        if(u==e)        {            printf("%d\n",cost);            return ;        }        if(res<cap&&(dp[u][res+1]==0||dp[u][res+1]>cost+val[u]))        {            dp[u][res+1]=cost+val[u];            q.push((node){u,dp[u][res+1],res+1});        }        for(int i=head[u]; i!=-1; i=edg[i].to)        {            int v=edg[i].v,dist=edg[i].dist;            if(res<dist)continue;            if(dp[v][res-dist]==0||dp[v][res-dist]>cost)            {                dp[v][res-dist]=cost;                q.push((node){v,cost,res-dist});            }        }    }    printf("impossible\n");    return ;}int main(){    while( scanf("%d%d",&n,&m)!=EOF)    {        init();        for(int i=0; i<n; i++)            scanf("%d",&val[i]);        int a,b,c;        for(int i=1; i<=m; i++)        {            scanf("%d%d%d",&a,&b,&c);            addedge(a,b,c);            addedge(b,a,c);        }        int q;        scanf("%d",&q);        while(q--)        {            scanf("%d%d%d",&cap,&s,&e);            bfs();        }    }    return 0;}
                ^


Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-02-17 09:22:32, Gzip enabled