0_0_13804183_27094.cpp:1:1958: fatal error: GCC4.9.2/lib/gcc/x86_64-w64-mingw32/4.9.2/include/iostream>usin: Invalid argument
#include<iostream>using namespace std;#define N 110#define inf 0x7ffffffftypedef struct node{ int adj; struct node * next; int w;}node,*pnode;node adjlist[N];typedef struct Heap{ int x; int dis;}Heap;Heap heap[1000];bool hash[N];int len,d[N],n,m;void insert(Heap in){ int u=++len; while(u>1&&heap[u>>1].dis>in.dis) { heap[u]=heap[u>>1]; u>>=1; } heap[u]=in; }Heap pop(){ Heap first=heap[1],last=heap[len--]; int u=1,v; while(2*u<=len) { v=u<<1; if(v+1<=len&&heap[v+1].dis<heap[v].dis) v++; if(heap[v].dis<last.dis) heap[u]=heap[v]; else break; u=v; } heap[u]=last; return first;}void insert_adjlist(int a,int b, int c){ pnode p,q; p=&adjlist[a]; while(p->next!=NULL) p=p->next; q=new node; q->adj=b; q->next=NULL; q->w=c; p->next=q; }int bfs(){ Heap min,in; pnode p; in.x=1; in.dis=0; d[1]=0; insert(in); while(len) { min=pop(); if(min.x==n) return min.dis; if(hash[min.x]) continue; hash[min.x]=true; p=adjlist[min.x].next; while(p!=NULL) { if(!hash[p->adj]) { in.x=p->adj; in.dis=min.dis+p->w; if(in.dis<d[in.x]) { d[in.x]=in.dis; insert(in); } } p=p->next; } } return -1;}int main(){ int i,a,b,c,min; while(scanf("%d%d",&n,&m),n+m) { for(i=1,len=0;i<=n;i++) { adjlist[i].next=NULL; hash[i]=false; d[i]=inf; } while(m--) { scanf("%d%d%d",&a,&b,&c); insert_adjlist(a,b,c); insert_adjlist(b,a,c); } min=bfs(); printf("%d\n",min); }}
^
compilation terminated.
|